Browse Source

Fix handling of responses without body; check that really no content is sent.

personal/stbuehler/wip
Stefan Bühler 13 years ago
parent
commit
49a99eb0e8
  1. 13
      src/main/connection.c
  2. 2
      src/main/response.c

13
src/main/connection.c

@ -42,12 +42,17 @@ static void forward_response_body(liConnection *con) {
}
}
if (vr->response.transfer_encoding & LI_HTTP_TRANSFER_ENCODING_CHUNKED) {
li_filter_chunked_encode(vr, con->raw_out, con->out);
if (con->raw_out->is_closed) {
li_chunkqueue_skip_all(con->out);
con->out->is_closed = TRUE;
} else {
li_chunkqueue_steal_all(con->raw_out, con->out);
if (vr->response.transfer_encoding & LI_HTTP_TRANSFER_ENCODING_CHUNKED) {
li_filter_chunked_encode(vr, con->raw_out, con->out);
} else {
li_chunkqueue_steal_all(con->raw_out, con->out);
}
if (con->out->is_closed) con->raw_out->is_closed = TRUE;
}
if (con->out->is_closed) con->raw_out->is_closed = TRUE;
if (con->raw_out->length > 0) {
li_ev_io_add_events(con->wrk->loop, &con->sock_watcher, EV_WRITE);
} else {

2
src/main/response.c

@ -43,6 +43,7 @@ gboolean li_response_send_headers(liConnection *con) {
/* They never have a content-body/length */
li_chunkqueue_reset(con->out);
con->out->is_closed = TRUE;
con->raw_out->is_closed = TRUE;
} 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 */
@ -64,6 +65,7 @@ gboolean li_response_send_headers(liConnection *con) {
/* content-length is set, but no body */
li_chunkqueue_reset(con->out);
con->out->is_closed = TRUE;
con->raw_out->is_closed = TRUE;
}
/* Status line */

Loading…
Cancel
Save