2 // ASIFormDataRequest.h
3 // Part of ASIHTTPRequest -> http://allseeing-i.com/ASIHTTPRequest
5 // Created by Ben Copsey on 07/11/2008.
6 // Copyright 2008-2009 All-Seeing Interactive. All rights reserved.
9 #import <Foundation/Foundation.h>
10 #import "ASIHTTPRequest.h"
11 #import "ASIHTTPRequestConfig.h"
13 typedef enum _ASIPostFormat {
14 ASIMultipartFormDataPostFormat = 0,
15 ASIURLEncodedPostFormat = 1
19 @interface ASIFormDataRequest : ASIHTTPRequest <NSCopying> {
21 // Parameters that will be POSTed to the url
22 NSMutableArray *postData;
24 // Files that will be POSTed to the url
25 NSMutableArray *fileData;
27 ASIPostFormat postFormat;
29 NSStringEncoding stringEncoding;
31 #if DEBUG_FORM_DATA_REQUEST
32 // 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
33 NSString *debugBodyString;
38 #pragma mark utilities
39 - (NSString*)encodeURL:(NSString *)string;
41 #pragma mark setup request
43 // Add a POST variable to the request
44 - (void)addPostValue:(id <NSObject>)value forKey:(NSString *)key;
46 // Set a POST variable for this request, clearing any others with the same key
47 - (void)setPostValue:(id <NSObject>)value forKey:(NSString *)key;
49 // Add the contents of a local file to the request
50 - (void)addFile:(NSString *)filePath forKey:(NSString *)key;
52 // Same as above, but you can specify the content-type and file name
53 - (void)addFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
55 // Add the contents of a local file to the request, clearing any others with the same key
56 - (void)setFile:(NSString *)filePath forKey:(NSString *)key;
58 // Same as above, but you can specify the content-type and file name
59 - (void)setFile:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
61 // Add the contents of an NSData object to the request
62 - (void)addData:(NSData *)data forKey:(NSString *)key;
64 // Same as above, but you can specify the content-type and file name
65 - (void)addData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
67 // Add the contents of an NSData object to the request, clearing any others with the same key
68 - (void)setData:(NSData *)data forKey:(NSString *)key;
70 // Same as above, but you can specify the content-type and file name
71 - (void)setData:(id)data withFileName:(NSString *)fileName andContentType:(NSString *)contentType forKey:(NSString *)key;
74 @property (assign) ASIPostFormat postFormat;
75 @property (assign) NSStringEncoding stringEncoding;