Skip to content

Commit 7adbccb

Browse files
Refine when content is expected (#2044)
Consider Content-Length and Transfer-Encoding headers when determining whether to expect content. Don't handle the HTTP/2 connection preface pseudo-method PRI. Fixes #2028.
1 parent eb10c22 commit 7adbccb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

httplib.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5381,10 +5381,14 @@ write_multipart_ranges_data(Stream &strm, const Request &req, Response &res,
53815381

53825382
inline bool expect_content(const Request &req) {
53835383
if (req.method == "POST" || req.method == "PUT" || req.method == "PATCH" ||
5384-
req.method == "PRI" || req.method == "DELETE") {
5384+
req.method == "DELETE") {
53855385
return true;
53865386
}
5387-
// TODO: check if Content-Length is set
5387+
if (req.has_header("Content-Length") &&
5388+
req.get_header_value_u64("Content-Length") > 0) {
5389+
return true;
5390+
}
5391+
if (is_chunked_transfer_encoding(req.headers)) { return true; }
53885392
return false;
53895393
}
53905394

0 commit comments

Comments
 (0)