ObjFW  Check-in [6bd37697f2]

Overview
Comment:OFHTTPClient: Status in delegate for redirection.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6bd37697f21f88275b37b7d1f77bd1e79e3ab27a493fd394b70e21d3bf69fcb3
User & Date: js on 2013-09-30 16:11:14
Other Links: manifest | tags
Context
2013-10-10
02:26
OFStream: Add -[unreadFromBuffer:length:]. check-in: 138a7a1934 user: js tags: trunk
2013-09-30
16:11
OFHTTPClient: Status in delegate for redirection. check-in: 6bd37697f2 user: js tags: trunk
16:01
OFHTTPClient: Improve 3xx status handling. check-in: 2c075194b3 user: js tags: trunk
Changes

Modified src/OFHTTPClient.h from [f3d93005f7] to [f17362c62b].

76
77
78
79
80
81
82

83
84
85
86
87

88
89
90
91
92
93
94
 *
 * This callback will only be called if the OFHTTPClient will follow a
 * redirect. If the maximum number of redirects has been reached already, this
 * callback will not be called.
 *
 * @param client The OFHTTPClient which wants to follow a redirect
 * @param URL The URL to which it will follow a redirect

 * @param request The request for which the OFHTTPClient wants to redirect
 * @return A boolean whether the OFHTTPClient should follow the redirect
 */
-	  (bool)client: (OFHTTPClient*)client
  shouldFollowRedirect: (OFURL*)URL

	       request: (OFHTTPRequest*)request;
@end

/*!
 * @brief A class for performing HTTP requests.
 */
@interface OFHTTPClient: OFObject







>





>







76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 *
 * This callback will only be called if the OFHTTPClient will follow a
 * redirect. If the maximum number of redirects has been reached already, this
 * callback will not be called.
 *
 * @param client The OFHTTPClient which wants to follow a redirect
 * @param URL The URL to which it will follow a redirect
 * @param statusCode The status code for the redirection
 * @param request The request for which the OFHTTPClient wants to redirect
 * @return A boolean whether the OFHTTPClient should follow the redirect
 */
-	  (bool)client: (OFHTTPClient*)client
  shouldFollowRedirect: (OFURL*)URL
	    statusCode: (int)statusCode
	       request: (OFHTTPRequest*)request;
@end

/*!
 * @brief A class for performing HTTP requests.
 */
@interface OFHTTPClient: OFObject

Modified src/OFHTTPClient.m from [e4f79357b9] to [bb33e92df8].

546
547
548
549
550
551
552
553
554
555

556
557
558
559
560
561
562
		OFURL *newURL;
		bool follow;

		newURL = [OFURL URLWithString: redirect
				relativeToURL: URL];

		if ([_delegate respondsToSelector:
		    @selector(client:shouldFollowRedirect:request:)])
			follow = [_delegate client: self
			      shouldFollowRedirect: newURL

					   request: request];
		else {
			/*
			 * 301, 302 and 307 should only redirect with user
			 * confirmation if the request method is not GET or
			 * HEAD. Asking the delegate and getting true returned
			 * is considered user confirmation.







|


>







546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
		OFURL *newURL;
		bool follow;

		newURL = [OFURL URLWithString: redirect
				relativeToURL: URL];

		if ([_delegate respondsToSelector:
		    @selector(client:shouldFollowRedirect:statusCode:request:)])
			follow = [_delegate client: self
			      shouldFollowRedirect: newURL
					statusCode: status
					   request: request];
		else {
			/*
			 * 301, 302 and 307 should only redirect with user
			 * confirmation if the request method is not GET or
			 * HEAD. Asking the delegate and getting true returned
			 * is considered user confirmation.