/* 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;
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)
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: