You've already forked cpp-httplib
Fix check for URI length to prevent incorrect HTTP 414 errors (#2046)
This commit is contained in:
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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user