http: allow trailing spaces (and only them) in request-line (like nginx)

This commit is contained in:
Azat Khuzhin 2018-10-22 23:56:19 +03:00
parent 6cf659b0bd
commit 254fbc81b4
No known key found for this signature in database
GPG Key ID: B86086848EF8686D

11
http.c
View File

@ -1686,8 +1686,9 @@ evhttp_parse_response_line(struct evhttp_request *req, char *line)
/* Parse the first line of a HTTP request */
static int
evhttp_parse_request_line(struct evhttp_request *req, char *line)
evhttp_parse_request_line(struct evhttp_request *req, char *line, size_t len)
{
char *eos = line + len;
char *method;
char *uri;
char *version;
@ -1696,6 +1697,12 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line)
size_t method_len;
enum evhttp_cmd_type type;
while (eos > line && *(eos-1) == ' ') {
*(eos-1) = '\0';
--eos;
--len;
}
/* Parse the request line */
method = strsep(&line, " ");
if (line == NULL)
@ -2009,7 +2016,7 @@ evhttp_parse_firstline_(struct evhttp_request *req, struct evbuffer *buffer)
switch (req->kind) {
case EVHTTP_REQUEST:
if (evhttp_parse_request_line(req, line) == -1)
if (evhttp_parse_request_line(req, line, len) == -1)
status = DATA_CORRUPTED;
break;
case EVHTTP_RESPONSE: