]> granicus.if.org Git - libevent/commitdiff
evhttp: Return 501 when we get an unrecognized method, not 400.
authorNick Mathewson <nickm@torproject.org>
Thu, 4 Nov 2010 16:39:41 +0000 (12:39 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 4 Nov 2010 16:39:41 +0000 (12:39 -0400)
http-internal.h
http.c

index b320e2d6aa4084c92004b811680dcaee65570c59..e32511e38d176f054efedea44e47b4e2c57d476e 100644 (file)
@@ -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 3aeecc9d9d88d63b20485ef41f84f71062d7c5c8..57d832f08995d45d7610c37950521f02859604f0 100644 (file)
--- 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) {