Commit 5634c7ff authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

shrpx: Ignore response body if HTTP status code is 1xx, 204 or 304

parent 3d694c89
...@@ -536,14 +536,15 @@ int htp_hdrs_completecb(http_parser *htp) ...@@ -536,14 +536,15 @@ int htp_hdrs_completecb(http_parser *htp)
!= 0) { != 0) {
return -1; return -1;
} }
unsigned int status = downstream->get_response_http_status();
if(downstream->get_request_method() == "HEAD") {
// Ignore the response body. HEAD response may contain // Ignore the response body. HEAD response may contain
// Content-Length or Transfer-Encoding: chunked. // Content-Length or Transfer-Encoding: chunked. Some server send
return 1; // 304 status code with nonzero Content-Length, but without response
} else { // body. See
return 0; // http://tools.ietf.org/html/draft-ietf-httpbis-p1-messaging-20#section-3.3
} return downstream->get_request_method() == "HEAD" ||
(100 <= status && status <= 199) || status == 204 ||
status == 304 ? 1 : 0;
} }
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment