@@ -32,11 +32,11 @@ #import "OFSandbox.h" #import "OFStdIOStream.h" #import "OFSystemInfo.h" #import "OFTCPSocket.h" #import "OFTLSStream.h" -#import "OFURL.h" +#import "OFURI.h" #ifdef HAVE_TLS_SUPPORT # import "ObjFWTLS.h" #endif @@ -60,12 +60,12 @@ #define KIBIBYTE (1024) @interface OFHTTP: OFObject { - OFArray OF_GENERIC(OFString *) *_URLs; - size_t _URLIndex; + OFArray OF_GENERIC(OFString *) *_URIs; + size_t _URIIndex; int _errorCode; OFString *_outputPath, *_currentFileName; bool _continue, _force, _detectFileName, _detectFileNameRequest; bool _detectedFileName, _quiet, _verbose, _insecure, _ignoreStatus; bool _useUnicode; @@ -77,11 +77,11 @@ OFStream *_output; unsigned long long _received, _length, _resumedFrom; ProgressBar *_progressBar; } -- (void)downloadNextURL; +- (void)downloadNextURI; @end #ifdef HAVE_TLS_SUPPORT void _reference_to_ObjFWTLS(void) @@ -95,11 +95,11 @@ static void help(OFStream *stream, bool full, int status) { [OFStdErr writeLine: OF_LOCALIZED(@"usage", - @"Usage: %[prog] -[cehHmoOPqv] url1 [url2 ...]", + @"Usage: %[prog] -[cehHmoOPqv] uri1 [uri2 ...]", @"prog", [OFApplication programName])]; if (full) { [stream writeString: @"\n"]; [stream writeLine: OF_LOCALIZED(@"full_usage", @@ -543,13 +543,13 @@ sandbox.allowsUnveil = false; [OFApplication of_activateSandbox: sandbox]; #endif _outputPath = [outputPath copy]; - _URLs = [optionsParser.remainingArguments copy]; + _URIs = [optionsParser.remainingArguments copy]; - if (_URLs.count < 1) + if (_URIs.count < 1) help(OFStdErr, false, 1); if (_quiet && _verbose) { [OFStdErr writeLine: OF_LOCALIZED(@"quiet_xor_verbose", @"%[prog]: -q / --quiet and -v / --verbose are mutually " @@ -565,14 +565,14 @@ @"mutually exclusive!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } - if (_outputPath != nil && _URLs.count > 1) { + if (_outputPath != nil && _URIs.count > 1) { [OFStdErr writeLine: - OF_LOCALIZED(@"output_only_with_one_url", - @"%[prog]: Cannot use -o / --output when more than one URL " + OF_LOCALIZED(@"output_only_with_one_uri", + @"%[prog]: Cannot use -o / --output when more than one URI " @"has been specified!", @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } @@ -583,11 +583,11 @@ _useUnicode = [OFSystemInfo isWindowsNT]; #else _useUnicode = ([OFLocale encoding] == OFStringEncodingUTF8); #endif - [self performSelector: @selector(downloadNextURL) afterDelay: 0]; + [self performSelector: @selector(downloadNextURI) afterDelay: 0]; } - (void)client: (OFHTTPClient *)client didCreateTLSStream: (OFTLSStream *)stream request: (OFHTTPRequest *)request @@ -607,11 +607,11 @@ [body writeBuffer: buffer length: length]; } } - (bool)client: (OFHTTPClient *)client - shouldFollowRedirect: (OFURL *)URL + shouldFollowRedirect: (OFURI *)URI statusCode: (short)statusCode request: (OFHTTPRequest *)request response: (OFHTTPResponse *)response { if (_verbose) { @@ -629,13 +629,13 @@ objc_autoreleasePoolPop(pool); } if (!_quiet) { if (_useUnicode) - [OFStdOut writeFormat: @"☇ %@", URL.string]; + [OFStdOut writeFormat: @"☇ %@", URI.string]; else - [OFStdOut writeFormat: @"< %@", URL.string]; + [OFStdOut writeFormat: @"< %@", URI.string]; } _length = 0; return true; @@ -645,11 +645,11 @@ didReadIntoBuffer: (void *)buffer length: (size_t)length exception: (id)exception { if (exception != nil) { - OFString *URL; + OFString *URI; [_progressBar stop]; [_progressBar draw]; [_progressBar release]; _progressBar = nil; @@ -658,21 +658,21 @@ [OFStdOut writeString: @"\n "]; [OFStdOut writeLine: OF_LOCALIZED(@"download_error", @"Error!")]; } - URL = [_URLs objectAtIndex: _URLIndex - 1]; + URI = [_URIs objectAtIndex: _URIIndex - 1]; [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_exception", - @"%[prog]: Failed to download <%[url]>!\n" + @"%[prog]: Failed to download <%[uri]>!\n" @" %[exception]", @"prog", [OFApplication programName], - @"url", URL, + @"uri", URI, @"exception", exception)]; _errorCode = 1; - [self performSelector: @selector(downloadNextURL) + [self performSelector: @selector(downloadNextURI) afterDelay: 0]; return false; } [_output writeBuffer: buffer length: length]; @@ -690,11 +690,11 @@ [OFStdOut writeString: @"\n "]; [OFStdOut writeLine: OF_LOCALIZED(@"download_done", @"Done!")]; } - [self performSelector: @selector(downloadNextURL) + [self performSelector: @selector(downloadNextURI) afterDelay: 0]; return false; } return true; @@ -814,38 +814,38 @@ if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED(@"download_resolve_host_failed", - @"%[prog]: Failed to download <%[url]>!\n" + @"%[prog]: Failed to download <%[uri]>!\n" @" Failed to resolve host: %[exception]", @"prog", [OFApplication programName], - @"url", request.URL.string, + @"uri", request.URI.string, @"exception", exception)]; } else if ([exception isKindOfClass: [OFConnectionFailedException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED(@"download_failed_connection_failed", - @"%[prog]: Failed to download <%[url]>!\n" + @"%[prog]: Failed to download <%[uri]>!\n" @" Connection failed: %[exception]", @"prog", [OFApplication programName], - @"url", request.URL.string, + @"uri", request.URI.string, @"exception", exception)]; } else if ([exception isKindOfClass: [OFInvalidServerResponseException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_invalid_server_response", - @"%[prog]: Failed to download <%[url]>!\n" + @"%[prog]: Failed to download <%[uri]>!\n" @" Invalid server response!", @"prog", [OFApplication programName], - @"url", request.URL.string)]; + @"uri", request.URI.string)]; } else if ([exception isKindOfClass: [OFUnsupportedProtocolException class]]) { if (!_quiet) [OFStdOut writeString: @"\n"]; @@ -878,14 +878,14 @@ @"write", @"Write failed"); [OFStdErr writeLine: OF_LOCALIZED( @"download_failed_read_or_write_failed", - @"%[prog]: Failed to download <%[url]>!\n" + @"%[prog]: Failed to download <%[uri]>!\n" @" %[error]: %[exception]", @"prog", [OFApplication programName], - @"url", request.URL.string, + @"uri", request.URI.string, @"error", error, @"exception", exception)]; } else if ([exception isKindOfClass: [OFHTTPRequestFailedException class]]) { short statusCode; @@ -898,20 +898,20 @@ statusCode = response.statusCode; codeString = [OFString stringWithFormat: @"%hd %@", statusCode, OFHTTPStatusCodeString(statusCode)]; [OFStdErr writeLine: OF_LOCALIZED(@"download_failed", - @"%[prog]: Failed to download <%[url]>!\n" + @"%[prog]: Failed to download <%[uri]>!\n" @" HTTP status code: %[code]", @"prog", [OFApplication programName], - @"url", request.URL.string, + @"uri", request.URI.string, @"code", codeString)]; } else @throw exception; _errorCode = 1; - [self performSelector: @selector(downloadNextURL) + [self performSelector: @selector(downloadNextURI) afterDelay: 0]; return; } after_exception_handling: @@ -922,14 +922,14 @@ _currentFileName = [fileNameFromContentDisposition( [response.headers objectForKey: @"Content-Disposition"]) copy]; _detectedFileName = true; - /* Handle this URL on the next -[downloadNextURL] call */ - _URLIndex--; + /* Handle this URI on the next -[downloadNextURI] call */ + _URIIndex--; - [self performSelector: @selector(downloadNextURL) + [self performSelector: @selector(downloadNextURI) afterDelay: 0]; return; } if ([_outputPath isEqual: @"-"]) @@ -984,47 +984,47 @@ next: [_currentFileName release]; _currentFileName = nil; - [self performSelector: @selector(downloadNextURL) afterDelay: 0]; + [self performSelector: @selector(downloadNextURI) afterDelay: 0]; } -- (void)downloadNextURL +- (void)downloadNextURI { - OFString *URLString = nil; - OFURL *URL; + OFString *URIString = nil; + OFURI *URI; OFMutableDictionary *clientHeaders; OFHTTPRequest *request; _received = _length = _resumedFrom = 0; if (_output != OFStdOut) [_output release]; _output = nil; - if (_URLIndex >= _URLs.count) + if (_URIIndex >= _URIs.count) [OFApplication terminateWithStatus: _errorCode]; @try { - URLString = [_URLs objectAtIndex: _URLIndex++]; - URL = [OFURL URLWithString: URLString]; + URIString = [_URIs objectAtIndex: _URIIndex++]; + URI = [OFURI URIWithString: URIString]; } @catch (OFInvalidFormatException *e) { - [OFStdErr writeLine: OF_LOCALIZED(@"invalid_url", - @"%[prog]: Invalid URL: <%[url]>!", + [OFStdErr writeLine: OF_LOCALIZED(@"invalid_uri", + @"%[prog]: Invalid URI: <%[uri]>!", @"prog", [OFApplication programName], - @"url", URLString)]; + @"uri", URIString)]; _errorCode = 1; goto next; } - if (![URL.scheme isEqual: @"http"] && ![URL.scheme isEqual: @"https"]) { + if (![URI.scheme isEqual: @"http"] && ![URI.scheme isEqual: @"https"]) { [OFStdErr writeLine: OF_LOCALIZED(@"invalid_scheme", - @"%[prog]: Invalid scheme: <%[url]>!", + @"%[prog]: Invalid scheme: <%[uri]>!", @"prog", [OFApplication programName], - @"url", URLString)]; + @"uri", URIString)]; _errorCode = 1; goto next; } @@ -1031,16 +1031,16 @@ clientHeaders = [[_clientHeaders mutableCopy] autorelease]; if (_detectFileName && !_detectedFileName) { if (!_quiet) { if (_useUnicode) - [OFStdOut writeFormat: @"⠒ %@", URL.string]; + [OFStdOut writeFormat: @"⠒ %@", URI.string]; else - [OFStdOut writeFormat: @"? %@", URL.string]; + [OFStdOut writeFormat: @"? %@", URI.string]; } - request = [OFHTTPRequest requestWithURL: URL]; + request = [OFHTTPRequest requestWithURI: URI]; request.headers = clientHeaders; request.method = OFHTTPRequestMethodHead; _detectFileNameRequest = true; [_HTTPClient asyncPerformRequest: request]; @@ -1055,11 +1055,11 @@ if (_currentFileName == nil) _currentFileName = [_outputPath copy]; if (_currentFileName == nil) - _currentFileName = [URL.path.lastPathComponent copy]; + _currentFileName = [URI.path.lastPathComponent copy]; if ([_currentFileName isEqual: @"/"]) { [_currentFileName release]; _currentFileName = nil; } @@ -1086,22 +1086,22 @@ } } if (!_quiet) { if (_useUnicode) - [OFStdOut writeFormat: @"⇣ %@", URL.string]; + [OFStdOut writeFormat: @"⇣ %@", URI.string]; else - [OFStdOut writeFormat: @"< %@", URL.string]; + [OFStdOut writeFormat: @"< %@", URI.string]; } - request = [OFHTTPRequest requestWithURL: URL]; + request = [OFHTTPRequest requestWithURI: URI]; request.headers = clientHeaders; request.method = _method; _detectFileNameRequest = false; [_HTTPClient asyncPerformRequest: request]; return; next: - [self performSelector: @selector(downloadNextURL) afterDelay: 0]; + [self performSelector: @selector(downloadNextURI) afterDelay: 0]; } @end