ObjFW  Check-in [9dd8014c27]

Overview
Comment:OFHTTPRequest: HTTP/1.1 introduces 307, handle it.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 9dd8014c275da9f13efd071289dd0626ce9c2ead52991d9f45d70c8ea01caefc
User & Date: js on 2012-03-08 16:30:47
Other Links: manifest | tags
Context
2012-03-08
18:04
OFHTTPRequest: Handle OFInvalidEncodingException due to incorrect reply. check-in: 59a1fd63eb user: js tags: trunk
16:30
OFHTTPRequest: HTTP/1.1 introduces 307, handle it. check-in: 9dd8014c27 user: js tags: trunk
2012-03-07
22:33
Implement HTTP/1.1 in OFHTTPRequest. check-in: 326634c95d user: js tags: trunk
Changes

Modified src/OFHTTPRequest.m from [b10e234803] to [96bd1084f3].

302
303
304
305
306
307
308

309
310
311
312
313
314
315
316
		do {
			tmp++;
		} while (*tmp == ' ');

		value = [OFString stringWithUTF8String: tmp];

		if ((redirects > 0 && (status == 301 || status == 302 ||

		    status == 303) && [key isEqual: @"Location"]) &&
		    (redirectsFromHTTPSToHTTPAllowed ||
		    [scheme isEqual: @"http"] ||
		    ![value hasPrefix: @"http://"])) {
			OFURL *new;
			BOOL follow;

			new = [OFURL URLWithString: value







>
|







302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
		do {
			tmp++;
		} while (*tmp == ' ');

		value = [OFString stringWithUTF8String: tmp];

		if ((redirects > 0 && (status == 301 || status == 302 ||
		    status == 303 || status == 307) &&
		    [key isEqual: @"Location"]) &&
		    (redirectsFromHTTPSToHTTPAllowed ||
		    [scheme isEqual: @"http"] ||
		    ![value hasPrefix: @"http://"])) {
			OFURL *new;
			BOOL follow;

			new = [OFURL URLWithString: value
379
380
381
382
383
384
385

386
387
388
389
390
391
392

					length = [sock readNBytes: length
						       intoBuffer: buffer];

					[delegate request: self
					   didReceiveData: buffer
					       withLength: length];


					bytesReceived += length;
					[data addNItems: length
					     fromCArray: buffer];

					toRead -= length;
				}







>







380
381
382
383
384
385
386
387
388
389
390
391
392
393
394

					length = [sock readNBytes: length
						       intoBuffer: buffer];

					[delegate request: self
					   didReceiveData: buffer
					       withLength: length];
					[pool2 releaseObjects];

					bytesReceived += length;
					[data addNItems: length
					     fromCArray: buffer];

					toRead -= length;
				}
440
441
442
443
444
445
446
447







448
449
450
451
452
453
454

	[serverHeaders makeImmutable];

	result = [[OFHTTPRequestResult alloc] initWithStatusCode: status
							 headers: serverHeaders
							    data: data];

	if (status != 200 && status != 301 && status != 302 && status != 303) {







		[result release];
		@throw [OFHTTPRequestFailedException
		    exceptionWithClass: isa
			   HTTPRequest: self
				result: result];
	}








|
>
>
>
>
>
>
>







442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463

	[serverHeaders makeImmutable];

	result = [[OFHTTPRequestResult alloc] initWithStatusCode: status
							 headers: serverHeaders
							    data: data];

	switch (status) {
	case 200:
	case 301:
	case 302:
	case 303:
	case 307:
		break;
	default:
		[result release];
		@throw [OFHTTPRequestFailedException
		    exceptionWithClass: isa
			   HTTPRequest: self
				result: result];
	}