@@ -285,17 +285,10 @@ newWithClass: isa]; status = (int)[[line substringFromIndex: 9 toIndex: 12] decimalValue]; - if (status != 200 && status != 301 && status != 302 && - status != 303) - @throw [OFHTTPRequestFailedException - newWithClass: isa - HTTPRequest: self - statusCode: status]; - serverHeaders = [OFMutableDictionary dictionary]; while ((line = [sock readLine]) != nil) { OFString *key, *value; const char *line_c = [line cString], *tmp; @@ -392,11 +385,17 @@ if (cl > SIZE_MAX) @throw [OFOutOfRangeException newWithClass: isa]; - if (cl != bytesReceived) + /* + * We only want to throw on these status codes as we + * will throw an OFHTTPRequestFailedException for all + * other status codes later. + */ + if (cl != bytesReceived && (status == 200 || + status == 301 || status == 302 || status == 303)) @throw [OFTruncatedDataException newWithClass: isa]; } /* @@ -409,10 +408,17 @@ result = [[OFHTTPRequestResult alloc] initWithStatusCode: status headers: serverHeaders data: data]; + + if (status != 200 && status != 301 && status != 302 && + status != 303) + @throw [OFHTTPRequestFailedException + newWithClass: isa + HTTPRequest: self + result: result]; } @finally { [pool release]; } return [result autorelease];