mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-17 10:59:39 +00:00
Extract has_framed_body and is_connection_persistent helpers
This commit is contained in:
1 parent
5c9285776e
commit
d755c43d58
1 file changed
+13
-6
@@ -8578,17 +8578,24 @@ write_multipart_ranges_data(Stream &strm, const Request &req, Response &res,
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool has_framed_body(const Request &req) {
|
||||||
|
return is_chunked_transfer_encoding(req.headers) ||
|
||||||
|
req.get_header_value_u64("Content-Length") > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool is_connection_persistent(const Request &req) {
|
||||||
|
auto conn = req.get_header_value("Connection");
|
||||||
|
if (conn == "close") { return false; }
|
||||||
|
if (req.version == "HTTP/1.0" && conn != "Keep-Alive") { return false; }
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool expect_content(const Request &req) {
|
inline bool expect_content(const Request &req) {
|
||||||
if (req.method == "POST" || req.method == "PUT" || req.method == "PATCH" ||
|
if (req.method == "POST" || req.method == "PUT" || req.method == "PATCH" ||
|
||||||
req.method == "DELETE") {
|
req.method == "DELETE") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (req.has_header("Content-Length") &&
|
return has_framed_body(req);
|
||||||
req.get_header_value_u64("Content-Length") > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (is_chunked_transfer_encoding(req.headers)) { return true; }
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|||||||
Reference in new issue
Block a user