mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-10-22 11:46:13 +00:00
Ignore Range on requests other than GET and HEAD
RFC 9110 14.2 defines range handling only for GET, and a server must ignore a Range header on any other method. The server parsed it on every method, so a POST with a Range got a 206 slice of the handler's response, or a 416 when the Range was malformed. Range is now parsed only for GET and HEAD; other methods get the whole response, and a handler can still read the header itself.
This commit is contained in:
1 parent
b83b385ed4
commit
32a0ca8b35
2 files changed
+28
-1
No files matched your search
@@ -15202,7 +15202,9 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
|
||||
}
|
||||
}
|
||||
|
||||
if (req.has_header("Range")) {
|
||||
// RFC 9110 14.2: range handling is defined only for GET (and so for HEAD)
|
||||
if ((req.method == "GET" || req.method == "HEAD") &&
|
||||
req.has_header("Range")) {
|
||||
const auto &range_header_value = req.get_header_value("Range");
|
||||
if (!detail::parse_range_header(range_header_value, req.ranges)) {
|
||||
connection_closed = true;
|
||||
|
||||
Reference in new issue
Block a user