@@ -7157,16 +7157,26 @@ Server::process_request(Stream &strm, const std::string &remote_addr,
71577157#endif
71587158#endif
71597159
7160+ auto req_line = line_reader.ptr ();
7161+
7162+ // Extract URI from the request line
7163+ std::string method, uri, version;
7164+ std::istringstream iss (req_line);
7165+ iss >> method >> uri >> version;
7166+
71607167 // Check if the request URI doesn't exceed the limit
7161- if (line_reader .size () > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
7168+ if (uri .size () > CPPHTTPLIB_REQUEST_URI_MAX_LENGTH) {
71627169 Headers dummy;
71637170 detail::read_headers (strm, dummy);
71647171 res.status = StatusCode::UriTooLong_414;
7172+ res.body = " Request URI too long: " + uri;
7173+ res.set_header (" Content-Type" , " text/plain" );
7174+
71657175 return write_response (strm, close_connection, req, res);
71667176 }
71677177
71687178 // Request line and headers
7169- if (!parse_request_line (line_reader. ptr () , req) ||
7179+ if (!parse_request_line (req_line , req) ||
71707180 !detail::read_headers (strm, req.headers )) {
71717181 res.status = StatusCode::BadRequest_400;
71727182 return write_response (strm, close_connection, req, res);
0 commit comments