Differences From Artifact [20b438d92f]:
- File
utils/ofhttp/OFHTTP.m
— part of check-in
[d375061886]
at
2018-02-27 20:36:22
on branch trunk
— OFHTTP{Client,Server}: Rename body to requestBody
This makes it more clear that this has nothing to do with the body of
the response, as the body of the response is read from the
OFHTTPResponse itself. (user: js, size: 26838) [annotate] [blame] [check-ins using]
To Artifact [3e501ee1e4]:
- File
utils/ofhttp/OFHTTP.m
— part of check-in
[892fbf97ac]
at
2018-03-11 20:38:05
on branch trunk
— ofhttp: Print headers as we receive them
This allows printing all headers of redirects in verbose mode. (user: js, size: 26699) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
531 532 533 534 535 536 537 | - (bool)client: (OFHTTPClient *)client shouldFollowRedirect: (OFURL *)URL statusCode: (int)statusCode request: (OFHTTPRequest *)request response: (OFHTTPResponse *)response context: (id)context { | < < < | 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | - (bool)client: (OFHTTPClient *)client shouldFollowRedirect: (OFURL *)URL statusCode: (int)statusCode request: (OFHTTPRequest *)request response: (OFHTTPResponse *)response context: (id)context { if (_verbose) { void *pool = objc_autoreleasePoolPush(); OFDictionary OF_GENERIC(OFString *, OFString *) *headers = [response headers]; OFEnumerator *keyEnumerator = [headers keyEnumerator]; OFEnumerator *objectEnumerator = [headers objectEnumerator]; |
︙ | ︙ | |||
630 631 632 633 634 635 636 | @"%[prog]: Failed to download <%[url]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], @"url", [[request URL] string], @"error", error, @"exception", e)]; } else if ([e isKindOfClass: [OFHTTPRequestFailedException class]]) { | < < < < | 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | @"%[prog]: Failed to download <%[url]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], @"url", [[request URL] string], @"error", error, @"exception", e)]; } else if ([e isKindOfClass: [OFHTTPRequestFailedException class]]) { [of_stderr writeLine: OF_LOCALIZED(@"download_failed", @"%[prog]: Failed to download <%[url]>!", @"prog", [OFApplication programName], @"url", [[request URL] string])]; } else @throw e; |
︙ | ︙ | |||
706 707 708 709 710 711 712 | next: [self performSelector: @selector(downloadNextURL) afterDelay: 0]; return false; } - (void)client: (OFHTTPClient *)client | > > | < < < < < < < < < < | < < | < < < < < < < < < | | < < > < > > > | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 | next: [self performSelector: @selector(downloadNextURL) afterDelay: 0]; return false; } - (void)client: (OFHTTPClient *)client didReceiveHeaders: (OFDictionary OF_GENERIC(OFString *, OFString *) *)headers statusCode: (int)statusCode request: (OFHTTPRequest *)request context: (id)context { if (!_quiet) { OFString *lengthString = [headers objectForKey: @"Content-Length"]; OFString *type = [headers objectForKey: @"Content-Type"]; [of_stdout writeFormat: @" ➜ %d\n", statusCode]; if (type == nil) type = OF_LOCALIZED(@"type_unknown", @"unknown"); if (lengthString != nil) _length = [lengthString decimalValue]; if (_length >= 0) { if (_resumedFrom + _length >= GIBIBYTE) { lengthString = [OFString stringWithFormat: @"%,.2f", (float)(_resumedFrom + _length) / GIBIBYTE]; lengthString = OF_LOCALIZED(@"size_gib", @"%[num] GiB", |
︙ | ︙ | |||
777 778 779 780 781 782 783 | } } else lengthString = OF_LOCALIZED(@"size_unknown", @"unknown"); if (_verbose) { void *pool = objc_autoreleasePoolPush(); | | < < | | | > | | | | | > | > > > > > > > > > > > > > > > > > | 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 | } } else lengthString = OF_LOCALIZED(@"size_unknown", @"unknown"); if (_verbose) { void *pool = objc_autoreleasePoolPush(); OFEnumerator OF_GENERIC(OFString *) *keyEnumerator = [headers keyEnumerator]; OFEnumerator OF_GENERIC(OFString *) *objectEnumerator = [headers objectEnumerator]; OFString *key, *object; if (statusCode / 100 == 2) { [of_stdout writeString: @" "]; [of_stdout writeLine: OF_LOCALIZED( @"info_name_unaligned", @"Name: %[name]", @"name", _currentFileName)]; } while ((key = [keyEnumerator nextObject]) != nil && (object = [objectEnumerator nextObject]) != nil) [of_stdout writeFormat: @" %@: %@\n", key, object]; objc_autoreleasePoolPop(pool); } else if (statusCode / 100 == 2) { [of_stdout writeString: @" "]; [of_stdout writeLine: OF_LOCALIZED(@"info_name", @"Name: %[name]", @"name", _currentFileName)]; [of_stdout writeString: @" "]; [of_stdout writeLine: OF_LOCALIZED(@"info_type", @"Type: %[type]", @"type", type)]; [of_stdout writeString: @" "]; [of_stdout writeLine: OF_LOCALIZED(@"info_size", @"Size: %[size]", @"size", lengthString)]; } } } - (void)client: (OFHTTPClient *)client didPerformRequest: (OFHTTPRequest *)request response: (OFHTTPResponse *)response context: (id)context { if ([context isEqual: @"detectFileName"]) { _currentFileName = [fileNameFromContentDisposition( [[response headers] objectForKey: @"Content-Disposition"]) copy]; _detectedFileName = true; [self performSelector: @selector(downloadNextURL) afterDelay: 0]; return; } if ([_outputPath isEqual: @"-"]) _output = of_stdout; else { if (!_continue && !_force && [[OFFileManager defaultManager] fileExistsAtPath: _currentFileName]) { [of_stderr writeLine: |
︙ | ︙ |