@@ -113,12 +113,11 @@ _hasContentLength = true; @try { _toRead = (size_t)[contentLength decimalValue]; } @catch (OFInvalidFormatException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } } } - (size_t)lowlevelReadIntoBuffer: (void*)buffer @@ -125,13 +124,12 @@ length: (size_t)length { if (_atEndOfStream) { OFReadFailedException *e; - e = [OFReadFailedException exceptionWithClass: [self class] - stream: self - requestedLength: length]; + e = [OFReadFailedException exceptionWithStream: self + requestedLength: length]; #ifndef _WIN32 e->_errNo = ENOTCONN; #else e->_errNo = WSAENOTCONN; @@ -180,11 +178,11 @@ _toRead -= length; if (_toRead == 0) if ([[_socket readLine] length] > 0) @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + exception]; return length; } else { void *pool = objc_autoreleasePoolPush(); OFString *line; @@ -191,12 +189,11 @@ of_range_t range; @try { line = [_socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } range = [line rangeOfString: @";"]; if (range.location != OF_NOT_FOUND) line = [line substringWithRange: @@ -204,12 +201,11 @@ @try { _toRead = (size_t)[line hexadecimalValue]; } @catch (OFInvalidFormatException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } if (_toRead == 0) { _atEndOfStream = true; @@ -216,16 +212,16 @@ if (_keepAlive) { @try { line = [_socket readLine]; } @catch (OFInvalidEncodingException *e) { @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + exception]; } if ([line length] > 0) @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + exception]; } else [_socket close]; } objc_autoreleasePoolPop(pool); @@ -306,12 +302,11 @@ [self close]; if ([[URL scheme] isEqual: @"https"]) { if (of_tls_socket_class == Nil) @throw [OFUnsupportedProtocolException - exceptionWithClass: [self class] - URL: URL]; + exceptionWithURL: URL]; socket = [[[of_tls_socket_class alloc] init] autorelease]; } else socket = [OFTCPSocket socket]; @@ -346,13 +341,11 @@ OFString *key, *object; int status; const char *type = NULL; if (![scheme isEqual: @"http"] && ![scheme isEqual: @"https"]) - @throw [OFUnsupportedProtocolException - exceptionWithClass: [self class] - URL: URL]; + @throw [OFUnsupportedProtocolException exceptionWithURL: URL]; /* Can we reuse the socket? */ if (_socket != nil && [[_lastURL scheme] isEqual: [URL scheme]] && [[_lastURL host] isEqual: [URL host]] && [_lastURL port] == [URL port]) { @@ -458,12 +451,11 @@ length: [POSTData count] * [POSTData itemSize]]; @try { line = [socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } /* * It's possible that the write succeeds on a connection that is * keep-alive, but the connection has already been closed by the remote @@ -479,24 +471,21 @@ [POSTData itemSize]]; @try { line = [socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } } if (![line hasPrefix: @"HTTP/"] || [line characterAtIndex: 8] != ' ') - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; version = [line substringWithRange: of_range(5, 3)]; if (![version isEqual: @"1.0"] && ![version isEqual: @"1.1"]) @throw [OFUnsupportedVersionException - exceptionWithClass: [self class] - version: version]; + exceptionWithVersion: version]; status = (int)[[line substringWithRange: of_range(9, 3)] decimalValue]; serverHeaders = [OFMutableDictionary dictionary]; @@ -506,31 +495,27 @@ char *keyC; @try { line = [socket readLine]; } @catch (OFInvalidEncodingException *e) { - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; } if (line == nil) - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; if ([line length] == 0) break; lineC = [line UTF8String]; if ((tmp = strchr(lineC, ':')) == NULL) - @throw [OFInvalidServerReplyException - exceptionWithClass: [self class]]; + @throw [OFInvalidServerReplyException exception]; if ((keyC = malloc(tmp - lineC + 1)) == NULL) @throw [OFOutOfMemoryException - exceptionWithClass: [self class] - requestedSize: tmp - lineC + 1]; + exceptionWithRequestedSize: tmp - lineC + 1]; memcpy(keyC, lineC, tmp - lineC); keyC[tmp - lineC] = '\0'; normalize_key(keyC); @@ -623,13 +608,12 @@ objc_autoreleasePoolPop(pool); [reply autorelease]; if (status / 100 != 2) @throw [OFHTTPRequestFailedException - exceptionWithClass: [self class] - request: request - reply: reply]; + exceptionWithRequest: request + reply: reply]; return reply; } - (void)close