From 964c0d100587d8134c85821deb19db50e425c33f Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 27 Jan 2013 16:20:14 +0900 Subject: [PATCH] shrpx: Don't return chunked response for pre-HTTP/1.1 request --- src/shrpx_spdy_session.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/shrpx_spdy_session.cc b/src/shrpx_spdy_session.cc index 5a7a27c9..25acf541 100644 --- a/src/shrpx_spdy_session.cc +++ b/src/shrpx_spdy_session.cc @@ -591,9 +591,18 @@ void on_ctrl_recv_callback status = downstream->get_response_http_status(); if(!((100 <= status && status <= 199) || status == 204 || status == 304)) { - // In SPDY, we are supporsed not to receive - // transfer-encoding. - downstream->add_response_header("transfer-encoding", "chunked"); + // Here we have response body but Content-Length is not known + // in advance. + if(downstream->get_request_major() <= 0 || + downstream->get_request_minor() <= 0) { + // We simply close connection for pre-HTTP/1.1 in this case. + downstream->set_response_connection_close(true); + } else { + // Otherwise, use chunked encoding to keep upstream + // connection open. In SPDY, we are supporsed not to + // receive transfer-encoding. + downstream->add_response_header("transfer-encoding", "chunked"); + } } }