nghttpx: Require content-length in SPDY upstream if FIN flag is not set

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-21 01:05:06 +09:00
parent 591f73e043
commit 823bb6c35e
1 changed files with 10 additions and 0 deletions

View File

@ -161,6 +161,7 @@ void on_ctrl_recv_callback
const char *scheme = 0; const char *scheme = 0;
const char *host = 0; const char *host = 0;
const char *method = 0; const char *method = 0;
const char *content_length = 0;
for(size_t i = 0; nv[i]; i += 2) { for(size_t i = 0; nv[i]; i += 2) {
if(strcmp(nv[i], ":path") == 0) { if(strcmp(nv[i], ":path") == 0) {
path = nv[i+1]; path = nv[i+1];
@ -172,6 +173,9 @@ void on_ctrl_recv_callback
} else if(strcmp(nv[i], ":host") == 0) { } else if(strcmp(nv[i], ":host") == 0) {
host = nv[i+1]; host = nv[i+1];
} else if(nv[i][0] != ':') { } else if(nv[i][0] != ':') {
if(strcmp(nv[i], "content-length") == 0) {
content_length = nv[i+1];
}
downstream->add_request_header(nv[i], nv[i+1]); downstream->add_request_header(nv[i], nv[i+1]);
} }
} }
@ -179,6 +183,12 @@ void on_ctrl_recv_callback
upstream->rst_stream(downstream, SPDYLAY_INTERNAL_ERROR); upstream->rst_stream(downstream, SPDYLAY_INTERNAL_ERROR);
return; return;
} }
// Require content-length if FIN flag is not set.
if((frame->syn_stream.hd.flags & SPDYLAY_CTRL_FLAG_FIN) == 0 &&
!content_length) {
upstream->rst_stream(downstream, SPDYLAY_PROTOCOL_ERROR);
return;
}
// SpdyDownstreamConnection examines request path to find // SpdyDownstreamConnection examines request path to find
// scheme. We construct abs URI for spdy_bridge mode as well as // scheme. We construct abs URI for spdy_bridge mode as well as
// spdy_proxy mode. // spdy_proxy mode.