nghttpd, nghttpx: Check END_STREAM flag in HEADERS other than request

This commit is contained in:
Tatsuhiro Tsujikawa 2014-05-24 15:02:46 +09:00
parent 9677788317
commit ebf0e4d787
2 changed files with 32 additions and 30 deletions

View File

@ -1258,13 +1258,13 @@ int hd_on_frame_recv_callback
break;
}
case NGHTTP2_HEADERS:
switch(frame->headers.cat) {
case NGHTTP2_HCAT_REQUEST: {
auto stream = hd->get_stream(frame->hd.stream_id);
if(!stream) {
return 0;
}
case NGHTTP2_HEADERS: {
auto stream = hd->get_stream(frame->hd.stream_id);
if(!stream) {
return 0;
}
if(frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
http2::normalize_headers(stream->headers);
if(!http2::check_http2_headers(stream->headers)) {
@ -1285,19 +1285,18 @@ int hd_on_frame_recv_callback
hd->submit_rst_stream(stream, NGHTTP2_PROTOCOL_ERROR);
return 0;
}
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
remove_stream_read_timeout(stream);
}
prepare_response(stream, hd);
} else {
add_stream_read_timeout(stream);
}
break;
}
default:
break;
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
remove_stream_read_timeout(stream);
prepare_response(stream, hd);
} else {
add_stream_read_timeout(stream);
}
break;
}
case NGHTTP2_SETTINGS:
if(frame->hd.flags & NGHTTP2_FLAG_ACK) {
hd->remove_settings_timer();

View File

@ -250,14 +250,11 @@ int on_begin_headers_callback(nghttp2_session *session,
namespace {
int on_request_headers(Http2Upstream *upstream,
Downstream *downstream,
nghttp2_session *session,
const nghttp2_frame *frame)
{
int rv;
auto downstream = upstream->find_downstream(frame->hd.stream_id);
if(!downstream) {
return 0;
}
downstream->normalize_request_headers();
auto& nva = downstream->get_request_headers();
@ -358,12 +355,13 @@ int on_frame_recv_callback
verbose_on_frame_recv_callback(session, frame, user_data);
}
auto upstream = static_cast<Http2Upstream*>(user_data);
auto downstream = upstream->find_downstream(frame->hd.stream_id);
if(!downstream) {
return 0;
}
switch(frame->hd.type) {
case NGHTTP2_DATA: {
auto downstream = upstream->find_downstream(frame->hd.stream_id);
if(!downstream) {
break;
}
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
downstream->end_upload_data();
downstream->set_request_state(Downstream::MSG_COMPLETE);
@ -371,12 +369,17 @@ int on_frame_recv_callback
break;
}
case NGHTTP2_HEADERS:
return on_request_headers(upstream, session, frame);
case NGHTTP2_PRIORITY: {
auto downstream = upstream->find_downstream(frame->hd.stream_id);
if(!downstream) {
break;
if(frame->headers.cat == NGHTTP2_HCAT_REQUEST) {
return on_request_headers(upstream, downstream, session, frame);
}
if(frame->hd.flags & NGHTTP2_FLAG_END_STREAM) {
downstream->end_upload_data();
downstream->set_request_state(Downstream::MSG_COMPLETE);
}
break;
case NGHTTP2_PRIORITY: {
// TODO comment out for now
// rv = downstream->change_priority(frame->priority.pri);
// if(rv != 0) {