Overview
Comment: | OFHTTPClient: Improve 3xx status handling. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
2c075194b39d9293fa56a7f36152ed20 |
User & Date: | js on 2013-09-30 16:01:40 |
Other Links: | manifest | tags |
Context
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 | |
2013-09-29
| ||
20:24 | Add simple non-colored output to tests. check-in: 1b6f73dc3a user: js tags: trunk | |
Changes
Modified src/OFHTTPClient.m from [95811098ef] to [e4f79357b9].
︙ | ︙ | |||
540 541 542 543 544 545 546 | if (redirects > 0 && (status == 301 || status == 302 || status == 303 || status == 307) && (redirect = [serverHeaders objectForKey: @"Location"]) != nil && (_insecureRedirectsAllowed || [scheme isEqual: @"http"] || ![redirect hasPrefix: @"http://"])) { OFURL *newURL; | | > > > > > > > > > > > > > > > > > > > > > > > > | 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | if (redirects > 0 && (status == 301 || status == 302 || status == 303 || status == 307) && (redirect = [serverHeaders objectForKey: @"Location"]) != nil && (_insecureRedirectsAllowed || [scheme isEqual: @"http"] || ![redirect hasPrefix: @"http://"])) { 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. */ if (method == OF_HTTP_REQUEST_METHOD_GET || method == OF_HTTP_REQUEST_METHOD_HEAD) follow = true; /* * 303 should always be redirected and converted to a * GET request. */ else if (status == 303) follow = true; else follow = false; } if (follow) { OFHTTPRequest *newRequest; newRequest = [OFHTTPRequest requestWithURL: newURL]; [newRequest setMethod: method]; [newRequest setHeaders: headers]; [newRequest setEntity: entity]; /* * 303 means the request should be converted to a GET * request before redirection. This also means stripping * the entity of the request. */ if (status == 303) { OFMutableDictionary *newHeaders; OFEnumerator *keyEnumerator, *objectEnumerator; id key, object; newHeaders = [OFMutableDictionary dictionary]; keyEnumerator = [headers keyEnumerator]; |
︙ | ︙ |