Skip to content

Commit

Permalink
http: allow trailing spaces (and only them) in request-line (like nginx)
Browse files Browse the repository at this point in the history
  • Loading branch information
azat committed Oct 22, 2018
1 parent 6cf659b commit 254fbc8
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 254fbc8

Please sign in to comment.