2
0
Fork 0

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

personal/stbuehler/wip
Stefan Bühler 2009-11-18 21:34:54 +01:00
parent 951c7e4e8d
commit 49a99eb0e8
2 changed files with 11 additions and 4 deletions

View File

@ -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 {

View File

@ -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 */