ASIFormDataRequest.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // ASIFormDataRequest.h
  3. // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
  4. //
  5. // Created by Ben Copsey on 07/11/2008.
  6. // Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "ASIHTTPRequest.h"
  10. #import "ASIHTTPRequestConfig.h"
  11. typedef enum _ASIPostFormat {
  12. ASIMultipartFormDataPostFormat = 0,
  13. ASIURLEncodedPostFormat = 1
  14. } ASIPostFormat;
  15. @interface ASIFormDataRequest : ASIHTTPRequest <NSCopying> {
  16. // Parameters that will be POSTed to the url
  17. NSMutableArray *postData;
  18. // Files that will be POSTed to the url
  19. NSMutableArray *fileData;
  20. ASIPostFormat postFormat;
  21. NSStringEncoding stringEncoding;
  22. #if DEBUG_FORM_DATA_REQUEST
  23. // Will store a string version of the request body that will be printed to the console when ASIHTTPREQUEST_DEBUG is set in GCC_PREPROCESSOR_DEFINITIONS
  24. NSString *debugBodyString;
  25. #endif
  26. }
  27. #pragma mark utilities
  28. - (NSString*)encodeURL:(NSString *)string;
  29. #pragma mark setup request
  30. // Add a POST variable to the request
  31. - (void)addPostValue:(id <NSObject>)value forKey:(NSString *)key;
  32. // Set a POST variable for this request, clearing any others with the same key
  33. - (void)setPostValue:(id <NSObject>)value forKey:(NSString *)key;
  34. // Add the contents of a local file to the request
  35. - (void)addFile:(NSString *)filePath forKey:(NSString *)key;
  36. // Same as above, but you can specify the content-type and file name
  37. - (void)addFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
  38. // Add the contents of a local file to the request, clearing any others with the same key
  39. - (void)setFile:(NSString *)filePath forKey:(NSString *)key;
  40. // Same as above, but you can specify the content-type and file name
  41. - (void)setFile:(NSString *)filePath withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
  42. // Add the contents of an NSData object to the request
  43. - (void)addData:(NSData *)data forKey:(NSString *)key;
  44. // Same as above, but you can specify the content-type and file name
  45. - (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
  46. // Add the contents of an NSData object to the request, clearing any others with the same key
  47. - (void)setData:(NSData *)data forKey:(NSString *)key;
  48. // Same as above, but you can specify the content-type and file name
  49. - (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
  50. @property (atomic, assign) ASIPostFormat postFormat;
  51. @property (atomic, assign) NSStringEncoding stringEncoding;
  52. @end