nghttpx: Reject multiple Content-Length even if their values are identical

This commit is contained in:
Tatsuhiro Tsujikawa 2015-01-24 00:07:28 +09:00
parent 0fcfe16dc5
commit 9a89db575a
6 changed files with 7 additions and 9 deletions

View File

@ -62,7 +62,7 @@ func TestH1H1MultipleRequestCL(t *testing.T) {
Host: %v
Test-Case: TestH1H1MultipleRequestCL
Content-Length: 0
Content-Length: 1
Content-Length: 0
`, st.authority)); err != nil {
t.Fatalf("Error io.WriteString() = %v", err)

View File

@ -234,7 +234,7 @@ func TestH2H1MultipleRequestCL(t *testing.T) {
name: "TestH2H1MultipleRequestCL",
header: []hpack.HeaderField{
pair("content-length", "1"),
pair("content-length", "2"),
pair("content-length", "1"),
},
})
if err != nil {
@ -372,7 +372,7 @@ func TestH2H1GracefulShutdown(t *testing.T) {
func TestH2H2MultipleResponseCL(t *testing.T) {
st := newServerTester([]string{"--http2-bridge"}, t, func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("content-length", "1")
w.Header().Add("content-length", "2")
w.Header().Add("content-length", "1")
})
defer st.Close()

View File

@ -64,7 +64,7 @@ func TestS3H1MultipleRequestCL(t *testing.T) {
name: "TestS3H1MultipleRequestCL",
header: []hpack.HeaderField{
pair("content-length", "1"),
pair("content-length", "2"),
pair("content-length", "1"),
},
})
if err != nil {

View File

@ -306,7 +306,7 @@ int index_headers(int *hdidx, Headers &headers, int64_t &content_length) {
if (len == -1) {
return -1;
}
if (content_length != -1 && content_length != len) {
if (content_length != -1) {
return -1;
}
content_length = len;

View File

@ -742,8 +742,7 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
downstream->set_response_state(Downstream::MSG_BAD_HEADER);
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}
auto cl = downstream->get_response_content_length();
if (cl != -1 && cl != len) {
if (downstream->get_response_content_length() != -1) {
http2session->submit_rst_stream(frame->hd.stream_id,
NGHTTP2_PROTOCOL_ERROR);
downstream->set_response_state(Downstream::MSG_BAD_HEADER);

View File

@ -206,8 +206,7 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
}
return 0;
}
auto cl = downstream->get_request_content_length();
if (cl != -1 && cl != len) {
if (downstream->get_request_content_length() != -1) {
if (upstream->error_reply(downstream, 400) != 0) {
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
}