Index: src/OFHTTPClient.m ================================================================== --- src/OFHTTPClient.m +++ src/OFHTTPClient.m @@ -59,10 +59,11 @@ - initWithClient: (OFHTTPClient *)client request: (OFHTTPRequest *)request redirects: (unsigned int)redirects context: (id)context; - (void)start; +- (void)closeAndReconnect; @end @interface OFHTTPClientResponse: OFHTTPResponse { OFTCPSocket *_socket; @@ -235,35 +236,10 @@ [_serverHeaders release]; [super dealloc]; } -- (void)closeAndReconnect -{ - OFURL *URL = [_request URL]; - OFTCPSocket *socket; - - [_client close]; - - if ([[URL scheme] isEqual: @"https"]) { - if (of_tls_socket_class == Nil) - @throw [OFUnsupportedProtocolException - exceptionWithURL: URL]; - - socket = [[[of_tls_socket_class alloc] init] - autorelease]; - } else - socket = [OFTCPSocket socket]; - - [socket asyncConnectToHost: [URL host] - port: [URL port] - target: self - selector: @selector(socketDidConnect:context: - exception:) - context: nil]; -} - - (void)createResponseWithSocket: (OFTCPSocket *)socket { OFURL *URL = [_request URL]; OFHTTPClientResponse *response; OFString *connectionHeader; @@ -714,10 +690,35 @@ afterDelay: 0]; } } else [self closeAndReconnect]; } + +- (void)closeAndReconnect +{ + OFURL *URL = [_request URL]; + OFTCPSocket *socket; + + [_client close]; + + if ([[URL scheme] isEqual: @"https"]) { + if (of_tls_socket_class == Nil) + @throw [OFUnsupportedProtocolException + exceptionWithURL: URL]; + + socket = [[[of_tls_socket_class alloc] init] + autorelease]; + } else + socket = [OFTCPSocket socket]; + + [socket asyncConnectToHost: [URL host] + port: [URL port] + target: self + selector: @selector(socketDidConnect:context: + exception:) + context: nil]; +} @end @implementation OFHTTPClientResponse @synthesize of_keepAlive = _keepAlive; Index: src/OFTarArchiveEntry.m ================================================================== --- src/OFTarArchiveEntry.m +++ src/OFTarArchiveEntry.m @@ -51,11 +51,11 @@ } static uintmax_t octalValueFromBuffer(const unsigned char *buffer, size_t length, uintmax_t max) { - uintmax_t value; + uintmax_t value = 0; if (length == 0) return 0; if (buffer[0] == 0x80) { Index: src/OFXMLParser.m ================================================================== --- src/OFXMLParser.m +++ src/OFXMLParser.m @@ -37,10 +37,33 @@ #import "OFUnboundPrefixException.h" typedef void (*state_function_t)(id, SEL); static SEL selectors[OF_XMLPARSER_NUM_STATES]; static state_function_t lookupTable[OF_XMLPARSER_NUM_STATES]; + +@interface OFXMLParser () +- (void)of_inByteOrderMarkState; +- (void)of_outsideTagState; +- (void)of_tagOpenedState; +- (void)of_inProcessingInstructionsState; +- (void)of_inTagNameState; +- (void)of_inCloseTagNameState; +- (void)of_inTagState; +- (void)of_inAttributeNameState; +- (void)of_expectAttributeEqualSignState; +- (void)of_expectAttributeDelimiterState; +- (void)of_inAttributeValueState; +- (void)of_expectTagCloseState; +- (void)of_expectSpaceOrTagCloseState; +- (void)of_inExclamationMarkState; +- (void)of_inCDATAOpeningState; +- (void)of_inCDATAState; +- (void)of_inCommentOpeningState; +- (void)of_inCommentState1; +- (void)of_inCommentState2; +- (void)of_inDOCTYPEState; +@end static OF_INLINE void appendToBuffer(OFMutableData *buffer, const char *string, of_string_encoding_t encoding, size_t length) { Index: src/runtime/ObjFW-RT.h ================================================================== --- src/runtime/ObjFW-RT.h +++ src/runtime/ObjFW-RT.h @@ -41,10 +41,13 @@ # define _Nonnull # endif # ifndef _Nullable # define _Nullable # endif +# ifndef _Null_unspecified +# define _Null_unspecified +# endif #endif #if !__has_feature(objc_arc) && !defined(__unsafe_unretained) # define __unsafe_unretained #endif Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -67,10 +67,12 @@ char *_buffer; OFStream *_output; intmax_t _received, _length, _resumedFrom; ProgressBar *_progressBar; } + +- (void)downloadNextURL; @end OF_APPLICATION_DELEGATE(OFHTTP) static void @@ -625,10 +627,70 @@ @throw e; [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } + +- (bool)stream: (OFHTTPResponse *)response + didReadIntoBuffer: (void *)buffer + length: (size_t)length + context: (id)context + exception: (OFException *)e +{ + if (e != nil) { + OFString *URL; + + [_progressBar stop]; + [_progressBar draw]; + [_progressBar release]; + _progressBar = nil; + + if (!_quiet) + [of_stdout writeString: @"\n Error!\n"]; + + URL = [_URLs objectAtIndex: _URLIndex - 1]; + [of_stderr writeLine: + OF_LOCALIZED(@"download_failed_exception", + @"%[prog]: Failed to download <%[url]>: %[exception]", + @"prog", [OFApplication programName], + @"url", URL, + @"exception", e)]; + + _errorCode = 1; + goto next; + } + + _received += length; + + [_output writeBuffer: buffer + length: length]; + + [_progressBar setReceived: _received]; + + if ([response isAtEndOfStream] || + (_length >= 0 && _received >= _length)) { + [_progressBar stop]; + [_progressBar draw]; + [_progressBar release]; + _progressBar = nil; + + if (!_quiet) { + [of_stdout writeString: @"\n "]; + [of_stdout writeLine: + OF_LOCALIZED(@"download_done", @"Done!")]; + } + + goto next; + } + + return true; + +next: + [self performSelector: @selector(downloadNextURL) + afterDelay: 0]; + return false; +} - (void)client: (OFHTTPClient *)client didPerformRequest: (OFHTTPRequest *)request response: (OFHTTPResponse *)response context: (id)context @@ -795,70 +857,10 @@ [self performSelector: @selector(downloadNextURL) afterDelay: 0]; } -- (bool)stream: (OFHTTPResponse *)response - didReadIntoBuffer: (void *)buffer - length: (size_t)length - context: (id)context - exception: (OFException *)e -{ - if (e != nil) { - OFString *URL; - - [_progressBar stop]; - [_progressBar draw]; - [_progressBar release]; - _progressBar = nil; - - if (!_quiet) - [of_stdout writeString: @"\n Error!\n"]; - - URL = [_URLs objectAtIndex: _URLIndex - 1]; - [of_stderr writeLine: - OF_LOCALIZED(@"download_failed_exception", - @"%[prog]: Failed to download <%[url]>: %[exception]", - @"prog", [OFApplication programName], - @"url", URL, - @"exception", e)]; - - _errorCode = 1; - goto next; - } - - _received += length; - - [_output writeBuffer: buffer - length: length]; - - [_progressBar setReceived: _received]; - - if ([response isAtEndOfStream] || - (_length >= 0 && _received >= _length)) { - [_progressBar stop]; - [_progressBar draw]; - [_progressBar release]; - _progressBar = nil; - - if (!_quiet) { - [of_stdout writeString: @"\n "]; - [of_stdout writeLine: - OF_LOCALIZED(@"download_done", @"Done!")]; - } - - goto next; - } - - return true; - -next: - [self performSelector: @selector(downloadNextURL) - afterDelay: 0]; - return false; -} - - (void)downloadNextURL { OFString *URLString = nil; OFURL *URL; OFMutableDictionary *clientHeaders;