@@ -413,11 +413,11 @@ OFString *contentLengthString = [_headers objectForKey: @"Content-Length"]; intmax_t contentLength = 0; if (contentLengthString != nil) { - if (chunked) + if (chunked || contentLengthString.length == 0) return [self sendErrorAndClose: 400]; @try { contentLength = contentLengthString.decimalValue; @@ -717,12 +717,11 @@ @throw [OFTruncatedDataException exception]; else @throw [OFInvalidFormatException exception]; } - _toRead = line.hexadecimalValue; - if (_toRead < 0) + if ((_toRead = line.hexadecimalValue) < 0) @throw [OFOutOfRangeException exception]; if (_toRead == 0) { _setAtEndOfStream = true; _toRead = -2;