Connection error if header continuation is employed by peer for now

This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-24 19:28:57 +09:00
parent e55abcd634
commit 2d41c99289
2 changed files with 28 additions and 3 deletions

View File

@ -1668,6 +1668,11 @@ int nghttp2_session_on_request_headers_received(nghttp2_session *session,
return nghttp2_session_handle_invalid_connection(session, frame, return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_PROTOCOL_ERROR); NGHTTP2_PROTOCOL_ERROR);
} }
/* Connection error if header continuation is employed for now */
if((frame->hd.flags & NGHTTP2_FLAG_END_HEADERS) == 0) {
return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_INTERNAL_ERROR);
}
if(session->goaway_flags) { if(session->goaway_flags) {
/* We don't accept new stream after GOAWAY is sent or received. */ /* We don't accept new stream after GOAWAY is sent or received. */
return 0; return 0;
@ -1720,6 +1725,11 @@ int nghttp2_session_on_response_headers_received(nghttp2_session *session,
return nghttp2_session_handle_invalid_connection(session, frame, return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_PROTOCOL_ERROR); NGHTTP2_PROTOCOL_ERROR);
} }
/* Connection error if header continuation is employed for now */
if((frame->hd.flags & NGHTTP2_FLAG_END_HEADERS) == 0) {
return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_INTERNAL_ERROR);
}
if((stream->shut_flags & NGHTTP2_SHUT_RD) == 0) { if((stream->shut_flags & NGHTTP2_SHUT_RD) == 0) {
stream->state = NGHTTP2_STREAM_OPENED; stream->state = NGHTTP2_STREAM_OPENED;
nghttp2_session_call_on_frame_received(session, frame); nghttp2_session_call_on_frame_received(session, frame);
@ -1752,6 +1762,11 @@ int nghttp2_session_on_push_response_headers_received(nghttp2_session *session,
return nghttp2_session_handle_invalid_connection(session, frame, return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_PROTOCOL_ERROR); NGHTTP2_PROTOCOL_ERROR);
} }
/* Connection error if header continuation is employed for now */
if((frame->hd.flags & NGHTTP2_FLAG_END_HEADERS) == 0) {
return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_INTERNAL_ERROR);
}
if(session->goaway_flags) { if(session->goaway_flags) {
/* We don't accept new stream after GOAWAY is sent or received. */ /* We don't accept new stream after GOAWAY is sent or received. */
return 0; return 0;
@ -1777,6 +1792,11 @@ int nghttp2_session_on_headers_received(nghttp2_session *session,
return nghttp2_session_handle_invalid_connection(session, frame, return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_PROTOCOL_ERROR); NGHTTP2_PROTOCOL_ERROR);
} }
/* Connection error if header continuation is employed for now */
if((frame->hd.flags & NGHTTP2_FLAG_END_HEADERS) == 0) {
return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_INTERNAL_ERROR);
}
if((stream->shut_flags & NGHTTP2_SHUT_RD) == 0) { if((stream->shut_flags & NGHTTP2_SHUT_RD) == 0) {
if(nghttp2_session_is_my_stream_id(session, frame->hd.stream_id)) { if(nghttp2_session_is_my_stream_id(session, frame->hd.stream_id)) {
if(stream->state == NGHTTP2_STREAM_OPENED) { if(stream->state == NGHTTP2_STREAM_OPENED) {
@ -2153,6 +2173,11 @@ int nghttp2_session_on_push_promise_received(nghttp2_session *session,
return nghttp2_session_handle_invalid_connection(session, frame, return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_PROTOCOL_ERROR); NGHTTP2_PROTOCOL_ERROR);
} }
/* Connection error if header continuation is employed for now */
if((frame->hd.flags & NGHTTP2_FLAG_END_PUSH_PROMISE) == 0) {
return nghttp2_session_handle_invalid_connection(session, frame,
NGHTTP2_INTERNAL_ERROR);
}
if(session->goaway_flags) { if(session->goaway_flags) {
/* We just dicard PUSH_PROMISE after GOAWAY is sent or /* We just dicard PUSH_PROMISE after GOAWAY is sent or
received. */ received. */

View File

@ -750,7 +750,7 @@ void test_nghttp2_session_on_headers_received(void)
NGHTTP2_PRI_DEFAULT, NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_CLOSING, NULL); NGHTTP2_STREAM_CLOSING, NULL);
frame.hd.stream_id = 3; frame.hd.stream_id = 3;
frame.hd.flags = NGHTTP2_FLAG_NONE; frame.hd.flags = NGHTTP2_FLAG_END_HEADERS;
CU_ASSERT(0 == nghttp2_session_on_headers_received(session, &frame, stream)); CU_ASSERT(0 == nghttp2_session_on_headers_received(session, &frame, stream));
/* See no counters are updated */ /* See no counters are updated */
CU_ASSERT(2 == user_data.frame_recv_cb_called); CU_ASSERT(2 == user_data.frame_recv_cb_called);
@ -762,7 +762,7 @@ void test_nghttp2_session_on_headers_received(void)
NGHTTP2_STREAM_OPENING, NULL); NGHTTP2_STREAM_OPENING, NULL);
/* half closed (remote) */ /* half closed (remote) */
frame.hd.flags = NGHTTP2_FLAG_END_STREAM; frame.hd.flags = NGHTTP2_FLAG_END_HEADERS | NGHTTP2_FLAG_END_STREAM;
frame.hd.stream_id = 2; frame.hd.stream_id = 2;
CU_ASSERT(0 == nghttp2_session_on_headers_received(session, &frame, stream)); CU_ASSERT(0 == nghttp2_session_on_headers_received(session, &frame, stream));
@ -2465,7 +2465,7 @@ void test_nghttp2_session_max_concurrent_streams(void)
NGHTTP2_PRI_DEFAULT, NGHTTP2_PRI_DEFAULT,
NGHTTP2_STREAM_OPENED, NULL); NGHTTP2_STREAM_OPENED, NULL);
nvlen = nghttp2_nv_array_from_cstr(&nva, nv); nvlen = nghttp2_nv_array_from_cstr(&nva, nv);
nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_NONE, 3, nghttp2_frame_headers_init(&frame.headers, NGHTTP2_FLAG_END_HEADERS, 3,
NGHTTP2_PRI_DEFAULT, nva, nvlen); NGHTTP2_PRI_DEFAULT, nva, nvlen);
session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 1; session->local_settings[NGHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS] = 1;