Skip to content

Commit

Permalink
lib-http: server: Do not generate a payload for a failure response fo…
Browse files Browse the repository at this point in the history
…r a HEAD request.
  • Loading branch information
stephanbosch authored and sirainen committed Jan 17, 2017
1 parent 1ffb3ca commit 998e94a
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/lib-http/http-server-request.c
Expand Up @@ -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;
}
Expand Down

0 comments on commit 998e94a

Please sign in to comment.