|
27 | 27 |
|
28 | 28 | #import "GCDWebServerRequest.h" |
29 | 29 |
|
| 30 | +/** |
| 31 | + * The GCDWebServerMultiPart class is an abstract class that wraps the content |
| 32 | + * of a part. |
| 33 | + */ |
30 | 34 | @interface GCDWebServerMultiPart : NSObject |
31 | | -@property(nonatomic, readonly) NSString* contentType; // Defaults to "text/plain" per specification if undefined |
| 35 | + |
| 36 | +/** |
| 37 | + * Returns the content type retrieved from the part headers or "text/plain" |
| 38 | + * if not available (per HTTP specifications). |
| 39 | + */ |
| 40 | +@property(nonatomic, readonly) NSString* contentType; |
| 41 | + |
| 42 | +/** |
| 43 | + * Returns the MIME type component of the content type for the part. |
| 44 | + */ |
32 | 45 | @property(nonatomic, readonly) NSString* mimeType; |
| 46 | + |
33 | 47 | @end |
34 | 48 |
|
| 49 | +/** |
| 50 | + * The GCDWebServerMultiPartArgument subclass of GCDWebServerMultiPart wraps |
| 51 | + * the content of a part as data in memory. |
| 52 | + */ |
35 | 53 | @interface GCDWebServerMultiPartArgument : GCDWebServerMultiPart |
| 54 | + |
| 55 | +/** |
| 56 | + * Returns the data for the part. |
| 57 | + */ |
36 | 58 | @property(nonatomic, readonly) NSData* data; |
37 | | -@property(nonatomic, readonly) NSString* string; // May be nil (only valid for text mime types) |
| 59 | + |
| 60 | +/** |
| 61 | + * Returns the data for the part interpreted as text. If the content |
| 62 | + * type of the part is not a text one, or if an error occurs, nil is returned. |
| 63 | + * |
| 64 | + * The text encoding used to interpret the data is extracted from the |
| 65 | + * "Content-Type" header or defaults to UTF-8. |
| 66 | + */ |
| 67 | +@property(nonatomic, readonly) NSString* string; |
| 68 | + |
38 | 69 | @end |
39 | 70 |
|
| 71 | +/** |
| 72 | + * The GCDWebServerMultiPartFile subclass of GCDWebServerMultiPart wraps |
| 73 | + * the content of a part as a file on disk. |
| 74 | + */ |
40 | 75 | @interface GCDWebServerMultiPartFile : GCDWebServerMultiPart |
41 | | -@property(nonatomic, readonly) NSString* fileName; // May be nil |
| 76 | + |
| 77 | +/** |
| 78 | + * Returns the file name retrieved from the part headers. |
| 79 | + */ |
| 80 | +@property(nonatomic, readonly) NSString* fileName; |
| 81 | + |
| 82 | +/** |
| 83 | + * Returns the path to the temporary file containing the part data. |
| 84 | + * |
| 85 | + * @warning This temporary file will be automatically deleted when the |
| 86 | + * GCDWebServerMultiPartFile is deallocated. If you want to preserve this file, |
| 87 | + * you must move it to a different location beforehand. |
| 88 | + */ |
42 | 89 | @property(nonatomic, readonly) NSString* temporaryPath; |
| 90 | + |
43 | 91 | @end |
44 | 92 |
|
| 93 | +/** |
| 94 | + * The GCDWebServerMultiPartFormRequest subclass of GCDWebServerRequest |
| 95 | + * parses the body of the HTTP request as a multipart encoded form. |
| 96 | + */ |
45 | 97 | @interface GCDWebServerMultiPartFormRequest : GCDWebServerRequest |
| 98 | + |
| 99 | +/** |
| 100 | + * Returns the argument parts from the multipart encoded form as |
| 101 | + * name / GCDWebServerMultiPartArgument pairs. |
| 102 | + */ |
46 | 103 | @property(nonatomic, readonly) NSDictionary* arguments; |
| 104 | + |
| 105 | +/** |
| 106 | + * Returns the files parts from the multipart encoded form as |
| 107 | + * name / GCDWebServerMultiPartFile pairs. |
| 108 | + */ |
47 | 109 | @property(nonatomic, readonly) NSDictionary* files; |
| 110 | + |
| 111 | +/** |
| 112 | + * Returns the MIME type for multipart encoded forms |
| 113 | + * i.e. "multipart/form-data". |
| 114 | + */ |
48 | 115 | + (NSString*)mimeType; |
| 116 | + |
49 | 117 | @end |
0 commit comments