ObjFW  Diff

Differences From Artifact [55acdcf8df]:

To Artifact [73f77fc69e]:


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68

69
70
71
72
73
74
75
#else
@protocol OFHTTPRequestDelegate
#endif
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/**
 * This callback is called when the OFHTTPRequest received the headers.
 *
 * \param request The OFHTTPRequest which received the headers
 * \param headers The headers received
 * \param statusCode The status code received
 */
-     (void)request: (OFHTTPRequest*)request
  didReceiveHeaders: (OFDictionary*)headers
     withStatusCode: (int)statusCode;

/**
 * This callback is called when the OFHTTPRequest received data.
 *
 * This is useful for example if you want to update a status display.
 *
 * \param request The OFHTTPRequest which received data
 * \param data The data the OFHTTPRequest received
 * \param length The length of the data received, in bytes
 */
-  (void)request: (OFHTTPRequest*)request
  didReceiveData: (const char*)data
      withLength: (size_t)length;

/**
 * This callback is called when the OFHTTPRequest will follow a redirect.

 *
 * If you want to get the headers and data for each redirect, set the number of
 * redirects to 0 and perform a new OFHTTPRequest for each redirect. However,
 * this callback will not be called then and you have to look at the status code
 * to detect a redirect.
 *
 * This callback will only be called if the OFHTTPRequest will follow a







|










|












|
>







37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#else
@protocol OFHTTPRequestDelegate
#endif
#ifdef OF_HAVE_OPTIONAL_PROTOCOLS
@optional
#endif
/**
 * \brief A callback which is called when an OFHTTPRequest received headers.
 *
 * \param request The OFHTTPRequest which received the headers
 * \param headers The headers received
 * \param statusCode The status code received
 */
-     (void)request: (OFHTTPRequest*)request
  didReceiveHeaders: (OFDictionary*)headers
     withStatusCode: (int)statusCode;

/**
 * \brief A callback which is called when an OFHTTPRequest received data.
 *
 * This is useful for example if you want to update a status display.
 *
 * \param request The OFHTTPRequest which received data
 * \param data The data the OFHTTPRequest received
 * \param length The length of the data received, in bytes
 */
-  (void)request: (OFHTTPRequest*)request
  didReceiveData: (const char*)data
      withLength: (size_t)length;

/**
 * \brief A callback which is called when an OFHTTPRequest will follow a
 *	  redirect.
 *
 * If you want to get the headers and data for each redirect, set the number of
 * redirects to 0 and perform a new OFHTTPRequest for each redirect. However,
 * this callback will not be called then and you have to look at the status code
 * to detect a redirect.
 *
 * This callback will only be called if the OFHTTPRequest will follow a
105
106
107
108
109
110
111


112
113
114
115
116


117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137


138
139
140
141
142
143
144
145
146
147
148
149


150
151
152
153
154
155
156
157
158
159
160
161


162
163
164
165
166
167
168
169
170
171
172
173


174
175
176
177
178
179
180
181
182
183
184
185


186
187
188
189
190
191
192
193
194
195
196
197


198
199
200
201
202
203
204
205
206
207
208
209
210
211
212


213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
@property (copy) OFDictionary *headers;
@property (assign) BOOL redirectsFromHTTPSToHTTPAllowed;
@property (retain) id <OFHTTPRequestDelegate> delegate;
@property (assign) BOOL storesData;
#endif

/**


 * \return A new, autoreleased OFHTTPRequest
 */
+ request;

/**


 * \param URL The URL for the request
 * \return A new, autoreleased OFHTTPRequest
 */
+ requestWithURL: (OFURL*)URL;

/**
 * Initializes an already allocated OFHTTPRequest with the specified URL.
 *
 * \param URL The URL for the request
 * \return An initialized OFHTTPRequest
 */
- initWithURL: (OFURL*)URL;

/**
 * Sets the URL for the HTTP request.
 *
 * \param URL The URL for the HTTP request
 */
- (void)setURL: (OFURL*)URL;

/**


 * \return The URL for the HTTP request
 */
- (OFURL*)URL;

/**
 * Sets the request type for the HTTP request.
 *
 * \param requestType The request type for the HTTP request
 */
- (void)setRequestType: (of_http_request_type_t)requestType;

/**


 * \return The request type for the HTTP request
 */
- (of_http_request_type_t)requestType;

/**
 * Sets the query string for the HTTP request.
 *
 * \param queryString The query string for the HTTP request
 */
- (void)setQueryString: (OFString*)queryString;

/**


 * \return The query string for the HTTP request
 */
- (OFString*)queryString;

/**
 * Sets a dictionary with headers for the HTTP request.
 *
 * \param headers A dictionary with headers for the HTTP request
 */
- (void)setHeaders: (OFDictionary*)headers;

/**


 * \return A dictionary with headers for the HTTP request.
 */
- (OFDictionary*)headers;

/**
 * Sets whether redirects from HTTPS to HTTP are allowed.
 *
 * \param allowed Whether redirects from HTTPS to HTTP are allowed
 */
- (void)setRedirectsFromHTTPSToHTTPAllowed: (BOOL)allowed;

/**


 * \return Whether redirects from HTTPS to HTTP are allowed
 */
- (BOOL)redirectsFromHTTPSToHTTPAllowed;

/**
 * Sets the delegate for the HTTP request.
 *
 * \param delegate The delegate for the HTTP request
 */
- (void)setDelegate: (id <OFHTTPRequestDelegate>)delegate;

/**


 * \return The delegate for the HTTP request.
 */
- (id <OFHTTPRequestDelegate>)delegate;

/**
 * Sets whether an OFDataArray with the data is created.
 *
 * Setting this to NO is only useful if you are using the delegate to handle the
 * data.
 *
 * \param storesData Whether to store the data in an OFDataArray
 */
- (void)setStoresData: (BOOL)storesData;

/**


 * \return Whether an OFDataArray with the data is created
 */
- (BOOL)storesData;

/**
 * Performs the HTTP request and returns an OFHTTPRequestResult.
 *
 * \return An OFHTTPRequestResult with the result of the HTTP request
 */
- (OFHTTPRequestResult*)perform;

/**
 * Performs the HTTP request and returns an OFHTTPRequestResult.
 *
 * \param redirects The maximum number of redirects after which no further
 *		    attempt is done to follow the redirect, but instead the
 *		    redirect is returned as an OFHTTPRequest
 * \return An OFHTTPRequestResult with the result of the HTTP request
 */
- (OFHTTPRequestResult*)performWithRedirects: (size_t)redirects;







>
>





>
>






|







|

|




>
>
|




|

|




>
>
|




|

|




>
>
|




|






>
>





|






>
>
|




|

|




>
>
|




|









>
>
|




|






|







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
@property (copy) OFDictionary *headers;
@property (assign) BOOL redirectsFromHTTPSToHTTPAllowed;
@property (retain) id <OFHTTPRequestDelegate> delegate;
@property (assign) BOOL storesData;
#endif

/**
 * \brief Creates a new OFHTTPRequest.
 *
 * \return A new, autoreleased OFHTTPRequest
 */
+ request;

/**
 * \brief Creates a new OFHTTPRequest with the specified URL.
 *
 * \param URL The URL for the request
 * \return A new, autoreleased OFHTTPRequest
 */
+ requestWithURL: (OFURL*)URL;

/**
 * \brief Initializes an already allocated OFHTTPRequest with the specified URL.
 *
 * \param URL The URL for the request
 * \return An initialized OFHTTPRequest
 */
- initWithURL: (OFURL*)URL;

/**
 * \brief Sets the URL of the HTTP request.
 *
 * \param URL The URL of the HTTP request
 */
- (void)setURL: (OFURL*)URL;

/**
 * \brief Returns the URL of the HTTP request.
 *
 * \return The URL of the HTTP request
 */
- (OFURL*)URL;

/**
 * \brief Sets the request type of the HTTP request.
 *
 * \param requestType The request type of the HTTP request
 */
- (void)setRequestType: (of_http_request_type_t)requestType;

/**
 * \brief Returns the request type of the HTTP request.
 *
 * \return The request type of the HTTP request
 */
- (of_http_request_type_t)requestType;

/**
 * \brief Sets the query string of the HTTP request.
 *
 * \param queryString The query string of the HTTP request
 */
- (void)setQueryString: (OFString*)queryString;

/**
 * \brief Returns the query string of the HTTP request.
 *
 * \return The query string of the HTTP request
 */
- (OFString*)queryString;

/**
 * \brief Sets a dictionary with headers for the HTTP request.
 *
 * \param headers A dictionary with headers for the HTTP request
 */
- (void)setHeaders: (OFDictionary*)headers;

/**
 * \brief Retrusn a dictionary with headers for the HTTP request.
 *
 * \return A dictionary with headers for the HTTP request.
 */
- (OFDictionary*)headers;

/**
 * \brief Sets whether redirects from HTTPS to HTTP are allowed.
 *
 * \param allowed Whether redirects from HTTPS to HTTP are allowed
 */
- (void)setRedirectsFromHTTPSToHTTPAllowed: (BOOL)allowed;

/**
 * \brief Returns whether redirects from HTTPS to HTTP will be allowed
 *
 * \return Whether redirects from HTTPS to HTTP will be allowed
 */
- (BOOL)redirectsFromHTTPSToHTTPAllowed;

/**
 * \brief Sets the delegate of the HTTP request.
 *
 * \param delegate The delegate of the HTTP request
 */
- (void)setDelegate: (id <OFHTTPRequestDelegate>)delegate;

/**
 * \brief Returns the delegate of the HTTP reqeust.
 *
 * \return The delegate of the HTTP request
 */
- (id <OFHTTPRequestDelegate>)delegate;

/**
 * \brief Sets whether an OFDataArray with the data should be created.
 *
 * Setting this to NO is only useful if you are using the delegate to handle the
 * data.
 *
 * \param storesData Whether to store the data in an OFDataArray
 */
- (void)setStoresData: (BOOL)storesData;

/**
 * \brief Returns whether an OFDataArray with the date should be created.
 *
 * \return Whether an OFDataArray with the data should be created
 */
- (BOOL)storesData;

/**
 * \brief Performs the HTTP request and returns an OFHTTPRequestResult.
 *
 * \return An OFHTTPRequestResult with the result of the HTTP request
 */
- (OFHTTPRequestResult*)perform;

/**
 * \brief Performs the HTTP request and returns an OFHTTPRequestResult.
 *
 * \param redirects The maximum number of redirects after which no further
 *		    attempt is done to follow the redirect, but instead the
 *		    redirect is returned as an OFHTTPRequest
 * \return An OFHTTPRequestResult with the result of the HTTP request
 */
- (OFHTTPRequestResult*)performWithRedirects: (size_t)redirects;
251
252
253
254
255
256
257


258
259
260
261
262


263
264
265
266
267




268
269
270
271
272
273
274
275
276
/// \cond internal
- initWithStatusCode: (short)status
	     headers: (OFDictionary*)headers
		data: (OFDataArray*)data;
/// \endcond

/**


 * \return The status code of the result of the HTTP request
 */
- (short)statusCode;

/**


 * \return The HTTP headers of the result of the HTTP request
 */
- (OFDictionary*)headers;

/**




 * \return The data returned for the HTTP request
 */
- (OFDataArray*)data;
@end

@interface OFObject (OFHTTPRequestDelegate) <OFHTTPRequestDelegate>
@end

extern Class of_http_request_tls_socket_class;







>
>





>
>
|




>
>
>
>
|








270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
/// \cond internal
- initWithStatusCode: (short)status
	     headers: (OFDictionary*)headers
		data: (OFDataArray*)data;
/// \endcond

/**
 * \brief Returns the state code of the result of the HTTP request.
 *
 * \return The status code of the result of the HTTP request
 */
- (short)statusCode;

/**
 * \brief Returns the headers of the result of the HTTP request.
 *
 * \return The headers of the result of the HTTP request
 */
- (OFDictionary*)headers;

/**
 * \brief Returns the data received for the HTTP request.
 *
 * Returns nil if storesData was set to NO.
 *
 * \return The data received for the HTTP request
 */
- (OFDataArray*)data;
@end

@interface OFObject (OFHTTPRequestDelegate) <OFHTTPRequestDelegate>
@end

extern Class of_http_request_tls_socket_class;