nghttpx: Stream error if mandatory HTTP/2 request header field is missing

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-25 23:21:07 +09:00
parent 39611f6f7f
commit 5d7b7a1691
1 changed files with 12 additions and 20 deletions

View File

@ -252,6 +252,7 @@ void on_frame_recv_callback
break; break;
} }
} }
}
if(!bad_req && if(!bad_req &&
!util::strieq("CONNECT", !util::strieq("CONNECT",
nva[req_hdidx[1]].value, nva[req_hdidx[1]].value,
@ -260,11 +261,8 @@ void on_frame_recv_callback
req_hdidx[4] == -1) { req_hdidx[4] == -1) {
// If content-length is missing, // If content-length is missing,
// Downstream::push_upload_data_chunk will fail and // Downstream::push_upload_data_chunk will fail and
// RST_STREAM will be sent. Therefore, error reply in // RST_STREAM will be sent.
// HEADERS may not be sent. So just issue RST_STREAM here. bad_req = true;
upstream->rst_stream(downstream, NGHTTP2_PROTOCOL_ERROR);
return;
}
} }
if(!bad_req) { if(!bad_req) {
for(; i < frame->headers.nvlen; ++i) { for(; i < frame->headers.nvlen; ++i) {
@ -279,13 +277,7 @@ void on_frame_recv_callback
} }
} }
if(bad_req) { if(bad_req) {
downstream->set_request_state(Downstream::HEADER_COMPLETE);
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
downstream->set_request_state(Downstream::MSG_COMPLETE);
}
if(upstream->error_reply(downstream, 400) != 0) {
upstream->rst_stream(downstream, NGHTTP2_PROTOCOL_ERROR); upstream->rst_stream(downstream, NGHTTP2_PROTOCOL_ERROR);
}
return; return;
} }