mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
http: allow trailing spaces (and only them) in request-line (like nginx)
This commit is contained in:
parent
6cf659b0bd
commit
254fbc81b4
11
http.c
11
http.c
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user