]> granicus.if.org Git - libevent/commitdiff
Allow bodies for GET/DELETE/OPTIONS/CONNECT
authorAzat Khuzhin <a3at.mail@gmail.com>
Sun, 29 Oct 2017 19:53:41 +0000 (22:53 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Mon, 30 Oct 2017 08:32:13 +0000 (11:32 +0300)
I checked with nginx, and via it's lua bindings it allows body for all
this methods. Also everybody knows that some of web-servers allows body
for GET even though this is not RFC conformant.

Refs: #408

http.c

diff --git a/http.c b/http.c
index d6dfeea14d8e46ed0e7211d088be64b58df1172e..db0fdc212ed20fcd71d4d3319cccb388c5e2fc84 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2129,7 +2129,7 @@ evhttp_get_body_length(struct evhttp_request *req)
                event_warnx("%s: we got no content length, but the "
                    "server wants to keep the connection open: %s.",
                    __func__, connection);
-               return (-1);
+               req->ntoread = 0;
        } else if (content_length == NULL) {
                req->ntoread = -1;
        } else {
@@ -2157,16 +2157,15 @@ evhttp_method_may_have_body(enum evhttp_cmd_type type)
        case EVHTTP_REQ_POST:
        case EVHTTP_REQ_PUT:
        case EVHTTP_REQ_PATCH:
-               return 1;
-       case EVHTTP_REQ_TRACE:
-               return 0;
-       /* XXX May any of the below methods have a body? */
+
        case EVHTTP_REQ_GET:
-       case EVHTTP_REQ_HEAD:
        case EVHTTP_REQ_DELETE:
        case EVHTTP_REQ_OPTIONS:
        case EVHTTP_REQ_CONNECT:
-               return 0;
+               return 1;
+
+       case EVHTTP_REQ_TRACE:
+       case EVHTTP_REQ_HEAD:
        default:
                return 0;
        }