]> granicus.if.org Git - libevent/commitdiff
http: replace EVHTTP_REQ_UNKNOWN_ with 0
authorAzat Khuzhin <azat@libevent.org>
Mon, 8 Apr 2019 19:27:33 +0000 (22:27 +0300)
committerAzat Khuzhin <azat@libevent.org>
Tue, 9 Apr 2019 21:51:27 +0000 (00:51 +0300)
From the server perspective the evhttp_response_phrase_internal() should
not be called with 0 before this patch, it will be called with
EVHTTP_REQ_UNKNOWN_ hence this patch should not change behavior.

Fixes: 68eb526d7b ("http: add WebDAV methods support")
Fixes: #789
Fixes: #796
Reported-by: Thomas Bernard <miniupnp@free.fr>
http-internal.h
http.c

index 1ae06b6a6a7e3916faf8eace1224912b1b9a4d6e..1f0b25644e94729a4fd6a2fad3853989e4e110c5 100644 (file)
@@ -31,9 +31,6 @@ 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 799cfb368f104cac2d168cefb65f5a8491a3cf1c..3969993f985b38ecaec99696ce8becba83851fe4 100644 (file)
--- a/http.c
+++ b/http.c
@@ -1756,7 +1756,7 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line, size_t len)
        const char *hostname;
        const char *scheme;
        size_t method_len;
-       enum evhttp_cmd_type type;
+       enum evhttp_cmd_type type = 0;
 
        while (eos > line && *(eos-1) == ' ') {
                *(eos-1) = '\0';
@@ -1778,7 +1778,6 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line, size_t len)
        version++;
 
        method_len = (uri - method) - 1;
-       type       = EVHTTP_REQ_UNKNOWN_;
 
        /* First line */
        switch (method_len) {
@@ -1941,13 +1940,13 @@ evhttp_parse_request_line(struct evhttp_request *req, char *line, size_t len)
                break;
        } /* switch */
 
-       if ((int)type == EVHTTP_REQ_UNKNOWN_) {
-               event_debug(("%s: bad method %s on request %p from %s",
+       if (!type) {
+               event_debug(("%s: bad method %s on request %p from %s",
                        __func__, method, req, req->remote_host));
-                /* No error yet; we'll give a better error later when
-                 * we see that req->type is unsupported. */
+               /* No error yet; we'll give a better error later when we see that
+                * req->type is unsupported in evhttp_handle_request(). */
        }
-           
+
        req->type = type;
 
        if (evhttp_parse_http_version(version, req) < 0)
@@ -3602,7 +3601,7 @@ evhttp_handle_request(struct evhttp_request *req, void *arg)
 
        bufferevent_disable(req->evcon->bufev, EV_READ);
 
-       if (req->type == 0 || req->uri == NULL) {
+       if (req->uri == NULL) {
                evhttp_send_error(req, req->response_code, NULL);
                return;
        }