Fail session if header compression failed on send

This commit is contained in:
Tatsuhiro Tsujikawa 2013-07-23 22:47:15 +09:00
parent 65cb559431
commit b7ff05c4c6
4 changed files with 44 additions and 0 deletions

View File

@ -1290,6 +1290,12 @@ int nghttp2_session_send(nghttp2_session *session)
nghttp2_outbound_item_free(item);
free(item);
if(framebuflen == NGHTTP2_ERR_HEADER_COMP) {
// If header compression error occurred, should terminiate
// connection.
framebuflen = nghttp2_session_fail_session(session,
NGHTTP2_INTERNAL_ERROR);
}
if(nghttp2_is_fatal(framebuflen)) {
return framebuflen;
} else {

View File

@ -108,6 +108,8 @@ int main(int argc, char* argv[])
test_nghttp2_session_send_headers_start_stream) ||
!CU_add_test(pSuite, "session_send_headers_reply",
test_nghttp2_session_send_headers_reply) ||
!CU_add_test(pSuite, "session_send_headers_header_comp_error",
test_nghttp2_session_send_headers_header_comp_error) ||
!CU_add_test(pSuite, "session_send_priority",
test_nghttp2_session_send_priority) ||
!CU_add_test(pSuite, "session_send_rst_stream",

View File

@ -1115,6 +1115,41 @@ void test_nghttp2_session_send_headers_reply(void)
nghttp2_session_del(session);
}
/* TODO Rewrite this test when header continuation is supported */
void test_nghttp2_session_send_headers_header_comp_error(void)
{
nghttp2_session *session;
nghttp2_session_callbacks callbacks;
const char *nv[] = { ":path", NULL, NULL };
size_t valuelen = 64*1024-1;
char *value = malloc(valuelen+1);
nghttp2_frame *frame = malloc(sizeof(nghttp2_frame));
nghttp2_nv *nva;
ssize_t nvlen;
memset(value, '0', valuelen);
value[valuelen] = '\0';
nv[1] = value;
memset(&callbacks, 0, sizeof(nghttp2_session_callbacks));
callbacks.send_callback = null_send_callback;
nghttp2_session_client_new(&session, &callbacks, NULL);
nvlen = nghttp2_nv_array_from_cstr(&nva, nv);
nghttp2_frame_headers_init(&frame->headers, NGHTTP2_FLAG_END_HEADERS, -1,
NGHTTP2_PRI_DEFAULT, nva, nvlen);
nghttp2_session_add_frame(session, NGHTTP2_CAT_CTRL, frame, NULL);
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(session->goaway_flags &
(NGHTTP2_GOAWAY_SEND | NGHTTP2_GOAWAY_FAIL_ON_SEND));
free(value);
nghttp2_session_del(session);
}
void test_nghttp2_session_send_priority(void)
{
nghttp2_session *session;

View File

@ -43,6 +43,7 @@ void test_nghttp2_session_on_window_update_received(void);
void test_nghttp2_session_on_data_received(void);
void test_nghttp2_session_send_headers_start_stream(void);
void test_nghttp2_session_send_headers_reply(void);
void test_nghttp2_session_send_headers_header_comp_error(void);
void test_nghttp2_session_send_priority(void);
void test_nghttp2_session_send_rst_stream(void);
void test_nghttp2_session_is_my_stream_id(void);