1
0
mirror of synced 2025-04-26 14:28:51 +03:00

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.
This commit is contained in:
Florian Albrechtskirchinger 2025-02-08 21:51:52 +01:00 committed by GitHub
parent eb10c22db1
commit 7adbccbaf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5381,10 +5381,14 @@ write_multipart_ranges_data(Stream &strm, const Request &req, Response &res,
inline bool expect_content(const Request &req) {
if (req.method == "POST" || req.method == "PUT" || req.method == "PATCH" ||
req.method == "PRI" || req.method == "DELETE") {
req.method == "DELETE") {
return true;
}
// TODO: check if Content-Length is set
if (req.has_header("Content-Length") &&
req.get_header_value_u64("Content-Length") > 0) {
return true;
}
if (is_chunked_transfer_encoding(req.headers)) { return true; }
return false;
}