︙ | | | ︙ | |
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
{
OFArray OF_GENERIC(OFString *) *_URLs;
size_t _URLIndex;
int _errorCode;
OFString *_outputPath, *_currentFileName;
bool _continue, _force, _detectFileName, _detectFileNameRequest;
bool _detectedFileName, _quiet, _verbose, _insecure, _ignoreStatus;
OFStream *_body;
of_http_request_method_t _method;
OFMutableDictionary *_clientHeaders;
OFHTTPClient *_HTTPClient;
char *_buffer;
OFStream *_output;
unsigned long long _received, _length, _resumedFrom;
|
>
|
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
{
OFArray OF_GENERIC(OFString *) *_URLs;
size_t _URLIndex;
int _errorCode;
OFString *_outputPath, *_currentFileName;
bool _continue, _force, _detectFileName, _detectFileNameRequest;
bool _detectedFileName, _quiet, _verbose, _insecure, _ignoreStatus;
bool _useUnicode;
OFStream *_body;
of_http_request_method_t _method;
OFMutableDictionary *_clientHeaders;
OFHTTPClient *_HTTPClient;
char *_buffer;
OFStream *_output;
unsigned long long _received, _length, _resumedFrom;
|
︙ | | | ︙ | |
573
574
575
576
577
578
579
580
581
582
583
584
585
586
|
@"prog", [OFApplication programName])];
[OFApplication terminateWithStatus: 1];
}
if (_insecure)
_HTTPClient.allowsInsecureRedirects = true;
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didCreateSocket: (OFTCPSocket *)sock
request: (OFHTTPRequest *)request
|
>
>
|
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
|
@"prog", [OFApplication programName])];
[OFApplication terminateWithStatus: 1];
}
if (_insecure)
_HTTPClient.allowsInsecureRedirects = true;
_useUnicode = ([OFLocale encoding] == OF_STRING_ENCODING_UTF_8);
[self performSelector: @selector(downloadNextURL)
afterDelay: 0];
}
- (void)client: (OFHTTPClient *)client
didCreateSocket: (OFTCPSocket *)sock
request: (OFHTTPRequest *)request
|
︙ | | | ︙ | |
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
|
(object = [objectEnumerator nextObject]) != nil)
[of_stdout writeFormat: @" %@: %@\n",
key, object];
objc_autoreleasePoolPop(pool);
}
if (!_quiet)
[of_stdout writeFormat: @"☇ %@", URL.string];
_length = 0;
return true;
}
- (bool)stream: (OFStream *)response
|
|
>
|
>
>
>
|
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
|
(object = [objectEnumerator nextObject]) != nil)
[of_stdout writeFormat: @" %@: %@\n",
key, object];
objc_autoreleasePoolPop(pool);
}
if (!_quiet) {
if (_useUnicode)
[of_stdout writeFormat: @"☇ %@", URL.string];
else
[of_stdout writeFormat: @"< %@", URL.string];
}
_length = 0;
return true;
}
- (bool)stream: (OFStream *)response
|
︙ | | | ︙ | |
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
|
_resumedFrom = 0;
if (!_quiet) {
OFString *lengthString =
[headers objectForKey: @"Content-Length"];
OFString *type = [headers objectForKey: @"Content-Type"];
[of_stdout writeFormat: @" ➜ %hd\n", statusCode];
if (type == nil)
type = OF_LOCALIZED(@"type_unknown", @"unknown");
if (lengthString != nil) {
_length = lengthString.unsignedLongLongValue;
|
>
|
>
>
|
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
|
_resumedFrom = 0;
if (!_quiet) {
OFString *lengthString =
[headers objectForKey: @"Content-Length"];
OFString *type = [headers objectForKey: @"Content-Type"];
if (_useUnicode)
[of_stdout writeFormat: @" ➜ %hd\n", statusCode];
else
[of_stdout writeFormat: @" -> %hd\n", statusCode];
if (type == nil)
type = OF_LOCALIZED(@"type_unknown", @"unknown");
if (lengthString != nil) {
_length = lengthString.unsignedLongLongValue;
|
︙ | | | ︙ | |
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
|
goto next;
}
}
if (!_quiet) {
_progressBar = [[ProgressBar alloc]
initWithLength: _length
resumedFrom: _resumedFrom];
[_progressBar setReceived: _received];
[_progressBar draw];
}
[_currentFileName release];
_currentFileName = nil;
|
|
>
|
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
|
goto next;
}
}
if (!_quiet) {
_progressBar = [[ProgressBar alloc]
initWithLength: _length
resumedFrom: _resumedFrom
useUnicode: _useUnicode];
[_progressBar setReceived: _received];
[_progressBar draw];
}
[_currentFileName release];
_currentFileName = nil;
|
︙ | | | ︙ | |
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
|
_errorCode = 1;
goto next;
}
clientHeaders = [[_clientHeaders mutableCopy] autorelease];
if (_detectFileName && !_detectedFileName) {
if (!_quiet)
[of_stdout writeFormat: @"⠒ %@", URL.string];
request = [OFHTTPRequest requestWithURL: URL];
request.headers = clientHeaders;
request.method = OF_HTTP_REQUEST_METHOD_HEAD;
_detectFileNameRequest = true;
[_HTTPClient asyncPerformRequest: request];
|
|
>
|
>
>
>
|
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
|
_errorCode = 1;
goto next;
}
clientHeaders = [[_clientHeaders mutableCopy] autorelease];
if (_detectFileName && !_detectedFileName) {
if (!_quiet) {
if (_useUnicode)
[of_stdout writeFormat: @"⠒ %@", URL.string];
else
[of_stdout writeFormat: @"? %@", URL.string];
}
request = [OFHTTPRequest requestWithURL: URL];
request.headers = clientHeaders;
request.method = OF_HTTP_REQUEST_METHOD_HEAD;
_detectFileNameRequest = true;
[_HTTPClient asyncPerformRequest: request];
|
︙ | | | ︙ | |
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
|
_resumedFrom];
[clientHeaders setObject: range
forKey: @"Range"];
} @catch (OFRetrieveItemAttributesFailedException *e) {
}
}
if (!_quiet)
[of_stdout writeFormat: @"⇣ %@", URL.string];
request = [OFHTTPRequest requestWithURL: URL];
request.headers = clientHeaders;
request.method = _method;
_detectFileNameRequest = false;
[_HTTPClient asyncPerformRequest: request];
|
|
>
|
>
>
>
|
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
|
_resumedFrom];
[clientHeaders setObject: range
forKey: @"Range"];
} @catch (OFRetrieveItemAttributesFailedException *e) {
}
}
if (!_quiet) {
if (_useUnicode)
[of_stdout writeFormat: @"⇣ %@", URL.string];
else
[of_stdout writeFormat: @"< %@", URL.string];
}
request = [OFHTTPRequest requestWithURL: URL];
request.headers = clientHeaders;
request.method = _method;
_detectFileNameRequest = false;
[_HTTPClient asyncPerformRequest: request];
|
︙ | | | ︙ | |