Commit b8a01f52 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

nghttpx: Require content-length in HTTP2 upstream if END_STREAM flag is not set

parent 823bb6c3
......@@ -208,7 +208,8 @@ void on_frame_recv_callback
}
// Assuming that nva is sorted by name.
const char *req_headers[] = {":host", ":method", ":path", ":scheme" };
const char *req_headers[] = {":host", ":method", ":path", ":scheme",
"content-length"};
const size_t req_hdlen = sizeof(req_headers)/sizeof(req_headers[0]);
int req_hdidx[req_hdlen];
memset(req_hdidx, -1, sizeof(req_hdidx));
......@@ -243,13 +244,23 @@ void on_frame_recv_callback
}
if(!bad_req) {
// Here :scheme is optional, because with CONNECT method, it
// is omitted.
// is omitted. content-length is mandatory if END_STREAM is
// not set.
for(j = 0; j < 3; ++j) {
if(req_hdidx[j] == -1) {
bad_req = true;
break;
}
}
if((frame->hd.flags & NGHTTP2_FLAG_END_STREAM) == 0 &&
req_hdidx[4] == -1) {
// If content-length is missing,
// Downstream::push_upload_data_chunk will fail and
// RST_STREAM will be sent. Therefore, error reply in
// HEADERS may not be sent. So just issue RST_STREAM here.
upstream->rst_stream(downstream, NGHTTP2_PROTOCOL_ERROR);
return;
}
}
if(!bad_req) {
for(; i < frame->headers.nvlen; ++i) {
......
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