Differences From Artifact [7ea7ca97c5]:
- File
utils/ofhttp/OFHTTP.m
— part of check-in
[0319fe1eb9]
at
2017-09-24 21:00:09
on branch trunk
— OFHTTPClient: Rename to -[asyncPerformRequest:]
This makes it clear that the request is handled asynchronously and makes
it possible to reintroduce a synchronous version later. (user: js, size: 26106) [annotate] [blame] [check-ins using]
To Artifact [e7a88133ce]:
- File utils/ofhttp/OFHTTP.m — part of check-in [c35ba05bbc] at 2017-09-25 00:02:44 on branch trunk — OFHTTPClient: Add support for passing a context (user: js, size: 26206) [annotate] [blame] [check-ins using]
| ︙ | ︙ | |||
496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket
request: (OFHTTPRequest *)request
{
if (_insecure && [socket respondsToSelector:
@selector(setCertificateVerificationEnabled:)])
[socket setCertificateVerificationEnabled: false];
}
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirect: (OFURL *)URL
statusCode: (int)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
{
if (!_quiet)
[of_stdout writeFormat: @" ➜ %d\n", statusCode];
if (_verbose) {
void *pool = objc_autoreleasePoolPush();
OFDictionary OF_GENERIC(OFString *, OFString *) *headers =
| > > | 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 |
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didCreateSocket: (OF_KINDOF(OFTCPSocket *))socket
request: (OFHTTPRequest *)request
context: (id)context
{
if (_insecure && [socket respondsToSelector:
@selector(setCertificateVerificationEnabled:)])
[socket setCertificateVerificationEnabled: false];
}
- (bool)client: (OFHTTPClient *)client
shouldFollowRedirect: (OFURL *)URL
statusCode: (int)statusCode
request: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
context: (id)context
{
if (!_quiet)
[of_stdout writeFormat: @" ➜ %d\n", statusCode];
if (_verbose) {
void *pool = objc_autoreleasePoolPush();
OFDictionary OF_GENERIC(OFString *, OFString *) *headers =
|
| ︙ | ︙ | |||
537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
return true;
}
- (void)client: (OFHTTPClient *)client
didEncounterException: (id)e
forRequest: (OFHTTPRequest *)request
{
if ([e isKindOfClass: [OFAddressTranslationFailedException class]]) {
if (!_quiet)
[of_stdout writeString: @"\n"];
[of_stderr writeLine:
OF_LOCALIZED(@"download_failed_address_translation",
| > | 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
return true;
}
- (void)client: (OFHTTPClient *)client
didEncounterException: (id)e
forRequest: (OFHTTPRequest *)request
context: (id)context
{
if ([e isKindOfClass: [OFAddressTranslationFailedException class]]) {
if (!_quiet)
[of_stdout writeString: @"\n"];
[of_stderr writeLine:
OF_LOCALIZED(@"download_failed_address_translation",
|
| ︙ | ︙ | |||
624 625 626 627 628 629 630 631 632 633 634 |
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
{
OFDictionary OF_GENERIC(OFString *, OFString *) *headers;
OFString *lengthString, *type;
| > < | | 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 |
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didPerformRequest: (OFHTTPRequest *)request
response: (OFHTTPResponse *)response
context: (id)context
{
OFDictionary OF_GENERIC(OFString *, OFString *) *headers;
OFString *lengthString, *type;
if ([context isEqual: @"detectFileName"]) {
_currentFileName = [fileNameFromContentDisposition(
[[response headers] objectForKey: @"Content-Disposition"])
copy];
_detectedFileName = true;
if (!_quiet)
[of_stdout writeFormat: @" ➜ %d\n",
|
| ︙ | ︙ | |||
904 905 906 907 908 909 910 | if (!_quiet) [of_stdout writeFormat: @"⠒ %@", [URL string]]; request = [OFHTTPRequest requestWithURL: URL]; [request setHeaders: clientHeaders]; [request setMethod: OF_HTTP_REQUEST_METHOD_HEAD]; | | > | 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 | if (!_quiet) [of_stdout writeFormat: @"⠒ %@", [URL string]]; request = [OFHTTPRequest requestWithURL: URL]; [request setHeaders: clientHeaders]; [request setMethod: OF_HTTP_REQUEST_METHOD_HEAD]; [_HTTPClient asyncPerformRequest: request context: @"detectFileName"]; return; } _detectedFileName = false; if (!_quiet) [of_stdout writeFormat: @"⇣ %@", [URL string]]; |
| ︙ | ︙ | |||
945 946 947 948 949 950 951 | } request = [OFHTTPRequest requestWithURL: URL]; [request setHeaders: clientHeaders]; [request setMethod: _method]; [request setBody: _body]; | | > | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 | } request = [OFHTTPRequest requestWithURL: URL]; [request setHeaders: clientHeaders]; [request setMethod: _method]; [request setBody: _body]; [_HTTPClient asyncPerformRequest: request context: nil]; return; next: [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } @end |