mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-15 01:08:27 +00:00
Fix check for URI length to prevent incorrect HTTP 414 errors (#2046)
This commit is contained in:
parent
b397c768e4
commit
a268d65c4f
2 changed files with 20 additions and 9 deletions
16
httplib.h
16
httplib.h
|
@ -7234,14 +7234,6 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
|
|||
#endif
|
||||
#endif
|
||||
|
||||
// Check if the request URI doesn't exceed the limit
|
||||
if (line_reader.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
|
||||
Headers dummy;
|
||||
detail::read_headers(strm, dummy);
|
||||
res.status = StatusCode::UriTooLong_414;
|
||||
return write_response(strm, close_connection, req, res);
|
||||
}
|
||||
|
||||
// Request line and headers
|
||||
if (!parse_request_line(line_reader.ptr(), req) ||
|
||||
!detail::read_headers(strm, req.headers)) {
|
||||
|
@ -7249,6 +7241,14 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
|
|||
return write_response(strm, close_connection, req, res);
|
||||
}
|
||||
|
||||
// Check if the request URI doesn't exceed the limit
|
||||
if (req.target.size() > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
|
||||
Headers dummy;
|
||||
detail::read_headers(strm, dummy);
|
||||
res.status = StatusCode::UriTooLong_414;
|
||||
return write_response(strm, close_connection, req, res);
|
||||
}
|
||||
|
||||
if (req.get_header_value("Connection") == "close") {
|
||||
connection_closed = true;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue