From 799053db8a2fc0b185769a1cb7b41b46634ed1de Mon Sep 17 00:00:00 2001 From: Azat Khuzhin Date: Mon, 8 Apr 2019 22:27:33 +0300 Subject: [PATCH] http: replace EVHTTP_REQ_UNKNOWN_ with 0 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 --- http-internal.h | 3 --- http.c | 15 +++++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/http-internal.h b/http-internal.h index 1ae06b6a..1f0b2564 100644 --- a/http-internal.h +++ b/http-internal.h @@ -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 799cfb36..3969993f 100644 --- 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; } -- 2.50.1