]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-http: server: Do not generate a payload for a failure response for a HEAD request.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 17 Jan 2017 00:37:25 +0000 (01:37 +0100)
committerStephan Bosch <stephan.bosch@dovecot.fi>
Tue, 17 Jan 2017 00:37:25 +0000 (01:37 +0100)
src/lib-http/http-server-request.c

index 32be2b8eac6700c2f8623bac191793e113add317..6d94bebc050f2607d14acdaf49262ebc164f2035 100644 (file)
@@ -302,12 +302,16 @@ http_server_request_create_fail_response(struct http_server_request *req,
 
        req->failed = TRUE;
 
+       i_assert(status / 100 != 1 && status != 204 && status != 304);
+
        resp = http_server_response_create(req, status, reason);
-       http_server_response_add_header
-               (resp, "Content-Type", "text/plain; charset=utf-8");
-       reason = t_strconcat(reason, "\r\n", NULL);
-       http_server_response_set_payload_data
-               (resp, (const unsigned char *)reason, strlen(reason));
+       if (!http_request_method_is(&req->req, "HEAD")) {
+               http_server_response_add_header
+                       (resp, "Content-Type", "text/plain; charset=utf-8");
+               reason = t_strconcat(reason, "\r\n", NULL);
+               http_server_response_set_payload_data
+                       (resp, (const unsigned char *)reason, strlen(reason));
+       }
 
        return resp;
 }