ObjFW  Check-in [4b1045c2d1]

Overview
Comment:OFHTTPClientDelegate: Improve a method name
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4b1045c2d1ce608bb6286f8d7e9d1013fb5f4cea5c12d7e7e5aad6c38c5db48c
User & Date: js on 2022-09-28 22:05:42
Other Links: manifest | tags
Context
2022-09-29
20:27
OFLocale: Rename a few methods check-in: 915bfc7431 user: js tags: trunk
2022-09-28
22:05
OFHTTPClientDelegate: Improve a method name check-in: 4b1045c2d1 user: js tags: trunk
22:02
Remove -[OFDictionary URIQueryString] check-in: f1bf64ca9f user: js tags: trunk
Changes

Modified src/OFHTTPClient.h from [cad337925c] to [d5da950339].

125
126
127
128
129
130
131
132
133
134
135
136





137
138
139
140
141
142
143
125
126
127
128
129
130
131





132
133
134
135
136
137
138
139
140
141
142
143







-
-
-
-
-
+
+
+
+
+







 *		  You are allowed to change the request's headers from this
 *		  callback and they will be used when following the redirect
 *		  (e.g. to set the cookies for the new URI), however, keep in
 *		  mind that this will change the request you originally passed.
 * @param response The response indicating the redirect
 * @return A boolean whether the OFHTTPClient should follow the redirect
 */
-	  (bool)client: (OFHTTPClient *)client
  shouldFollowRedirect: (OFURI *)URI
	    statusCode: (short)statusCode
	       request: (OFHTTPRequest *)request
	      response: (OFHTTPResponse *)response;
-	       (bool)client: (OFHTTPClient *)client
  shouldFollowRedirectToURI: (OFURI *)URI
		 statusCode: (short)statusCode
		    request: (OFHTTPRequest *)request
		   response: (OFHTTPResponse *)response;
@end

/**
 * @class OFHTTPClient OFHTTPClient.h ObjFW/OFHTTPClient.h
 *
 * @brief A class for performing HTTP requests.
 */

Modified src/OFHTTPClient.m from [5fbd446b75] to [fbd23d3190].

355
356
357
358
359
360
361
362
363



364
365

366
367
368
369
370
371
372
355
356
357
358
359
360
361


362
363
364
365

366
367
368
369
370
371
372
373







-
-
+
+
+

-
+







		if (!_client->_allowsInsecureRedirects &&
		    [URI.scheme caseInsensitiveCompare: @"https"] ==
		    OFOrderedSame &&
		    [newURIScheme caseInsensitiveCompare: @"http"] ==
		    OFOrderedSame)
			follow = false;

		if (follow && [_client->_delegate respondsToSelector: @selector(
		    client:shouldFollowRedirect:statusCode:request:response:)])
		if (follow && [_client->_delegate respondsToSelector:
		    @selector(client:shouldFollowRedirectToURI:statusCode:
		    request:response:)])
			follow = [_client->_delegate client: _client
				       shouldFollowRedirect: newURI
				  shouldFollowRedirectToURI: newURI
						 statusCode: _status
						    request: _request
						   response: response];
		else if (follow)
			follow = defaultShouldFollow(_request.method, _status);

		if (follow) {
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208





1209
1210
1211
1212
1213
1214
1215
1216







1217
1218
1219
1220
1221
1222
1223
1198
1199
1200
1201
1202
1203
1204





1205
1206
1207
1208
1209
1210







1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224







-
-
-
-
-
+
+
+
+
+

-
-
-
-
-
-
-
+
+
+
+
+
+
+







	    @selector(client:didReceiveHeaders:statusCode:request:)])
		[_delegate     client: client
		    didReceiveHeaders: headers
			   statusCode: statusCode
			      request: request];
}

-	  (bool)client: (OFHTTPClient *)client
  shouldFollowRedirect: (OFURI *)URI
	    statusCode: (short)statusCode
	       request: (OFHTTPRequest *)request
	      response: (OFHTTPResponse *)response
-	       (bool)client: (OFHTTPClient *)client
  shouldFollowRedirectToURI: (OFURI *)URI
		 statusCode: (short)statusCode
		    request: (OFHTTPRequest *)request
		   response: (OFHTTPResponse *)response
{
	if ([_delegate respondsToSelector: @selector(client:
	    shouldFollowRedirect:statusCode:request:response:)])
		return [_delegate client: client
		    shouldFollowRedirect: URI
			      statusCode: statusCode
				 request: request
				response: response];
	if ([_delegate respondsToSelector: @selector(
	    client:shouldFollowRedirectToURI:statusCode:request:response:)])
		return [_delegate      client: client
		    shouldFollowRedirectToURI: URI
				   statusCode: statusCode
				      request: request
				     response: response];
	else
		return defaultShouldFollow(request.method, statusCode);
}
@end

@implementation OFHTTPClient
@synthesize delegate = _delegate;

Modified utils/ofhttp/OFHTTP.m from [d8707f71b6] to [84e58d6177].

604
605
606
607
608
609
610
611
612
613
614
615





616
617
618
619
620
621
622
604
605
606
607
608
609
610





611
612
613
614
615
616
617
618
619
620
621
622







-
-
-
-
-
+
+
+
+
+







	while (!_body.atEndOfStream) {
		char buffer[4096];
		size_t length = [_body readIntoBuffer: buffer length: 4096];
		[body writeBuffer: buffer length: length];
	}
}

-	  (bool)client: (OFHTTPClient *)client
  shouldFollowRedirect: (OFURI *)URI
	    statusCode: (short)statusCode
	       request: (OFHTTPRequest *)request
	      response: (OFHTTPResponse *)response
-	       (bool)client: (OFHTTPClient *)client
  shouldFollowRedirectToURI: (OFURI *)URI
		 statusCode: (short)statusCode
		    request: (OFHTTPRequest *)request
		   response: (OFHTTPResponse *)response
{
	if (_verbose) {
		void *pool = objc_autoreleasePoolPush();
		OFDictionary OF_GENERIC(OFString *, OFString *) *headers =
		    response.headers;
		OFEnumerator *keyEnumerator = [headers keyEnumerator];
		OFEnumerator *objectEnumerator = [headers objectEnumerator];