Browse Source

Fix response.c to not send chunked encoding/.. for head requests with no content

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent
commit
f96e35e03a
  1. 10
      src/main/response.c

10
src/main/response.c

@ -43,10 +43,12 @@ gboolean li_response_send_headers(liConnection *con) {
/* They never have a content-body/length */
li_chunkqueue_reset(con->out);
con->out->is_closed = TRUE;
} else if (con->out->is_closed && (vr->request.http_method != LI_HTTP_METHOD_HEAD || con->out->length > 0)) {
/* do not send content-length: 0 if backend already skipped content generation for HEAD */
g_string_printf(con->wrk->tmp_str, "%"L_GOFFSET_FORMAT, con->out->length);
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Length"), GSTR_LEN(con->wrk->tmp_str));
} else if (con->out->is_closed) {
if (vr->request.http_method != LI_HTTP_METHOD_HEAD || con->out->length > 0) {
/* do not send content-length: 0 if backend already skipped content generation for HEAD */
g_string_printf(con->wrk->tmp_str, "%"L_GOFFSET_FORMAT, con->out->length);
li_http_header_overwrite(vr->response.headers, CONST_STR_LEN("Content-Length"), GSTR_LEN(con->wrk->tmp_str));
}
} else if (con->keep_alive && vr->request.http_version == LI_HTTP_VERSION_1_1) {
/* TODO: maybe someone set a content length header? */
if (!(vr->response.transfer_encoding & LI_HTTP_TRANSFER_ENCODING_CHUNKED)) {

Loading…
Cancel
Save