Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions evhtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1872,6 +1872,7 @@ htp__create_reply_(evhtp_request_t * request, evhtp_res code)
{
struct evbuffer * buf;
const char * content_type;
const char * transfer_encoding;
char res_buf[2048];
int sres;
size_t out_len;
Expand All @@ -1881,6 +1882,7 @@ htp__create_reply_(evhtp_request_t * request, evhtp_res code)


content_type = evhtp_header_find(request->headers_out, "Content-Type");
transfer_encoding = evhtp_header_find(request->headers_out, "Transfer-Encoding");
out_len = evbuffer_get_length(request->buffer_out);

if ((buf = request->conn->scratch_buf) == NULL)
Expand All @@ -1899,7 +1901,8 @@ htp__create_reply_(evhtp_request_t * request, evhtp_res code)
{
/* add extra headers (like content-length/type) if not already present */

if (!evhtp_header_find(request->headers_out, "Content-Length"))
if (!evhtp_header_find(request->headers_out, "Content-Length") &&
(!transfer_encoding || strcmp(transfer_encoding, "chunked") != 0))
{
/* convert the buffer_out length to a string and set
* and add the new Content-Length header.
Expand All @@ -1921,7 +1924,8 @@ htp__create_reply_(evhtp_request_t * request, evhtp_res code)
evhtp_header_new("Connection", "close", 0, 0));
}

if (!evhtp_header_find(request->headers_out, "Content-Length"))
if (!evhtp_header_find(request->headers_out, "Content-Length") &&
(!transfer_encoding || strcmp(transfer_encoding, "chunked") != 0))
{
evhtp_headers_add_header(request->headers_out,
evhtp_header_new("Content-Length", "0", 0, 0));
Expand Down