From 536311a46b407902ca0ee52d504c327ec54cfdf1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Thu, 4 Nov 2010 12:39:41 -0400 Subject: [PATCH] evhttp: Return 501 when we get an unrecognized method, not 400. --- http-internal.h | 3 +++ http.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/http-internal.h b/http-internal.h index b320e2d6..e32511e3 100644 --- a/http-internal.h +++ b/http-internal.h @@ -41,6 +41,9 @@ struct evbuffer; struct addrinfo; struct evhttp_request; +/* Indicates an unknown request method. */ +#define _EVHTTP_REQ_UNKNOWN (1<<15) + enum evhttp_connection_state { EVCON_DISCONNECTED, /**< not currently connected not trying either*/ EVCON_CONNECTING, /**< tries to currently connect */ diff --git a/http.c b/http.c index 3aeecc9d..57d832f0 100644 --- a/http.c +++ b/http.c @@ -1398,9 +1398,11 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line) } else if (strcmp(method, "PATCH") == 0) { req->type = EVHTTP_REQ_PATCH; } else { + req->type = _EVHTTP_REQ_UNKNOWN; event_debug(("%s: bad method %s on request %p from %s", __func__, method, req, req->remote_host)); - return (-1); + /* No error yet; we'll give a better error later when + * we see that req->type is unsupported. */ } if (strcmp(version, "HTTP/1.0") == 0) {