Do not RST_STREAM for DATA against nonexistent stream

This may be useful to the misbehaving implementation, but it could
result in lots of RST_STREAM, so just ignore it for now.
This commit is contained in:
Tatsuhiro Tsujikawa 2013-08-10 15:13:53 +09:00
parent a1dd866ebc
commit a52ca391a2
2 changed files with 15 additions and 6 deletions

View File

@ -2605,10 +2605,15 @@ int nghttp2_session_on_data_received(nghttp2_session *session,
in this state it MUST respond with a stream error (Section
5.4.2) of type STREAM_CLOSED.
*/
if(stream->state != NGHTTP2_STREAM_CLOSING) {
error_code = NGHTTP2_STREAM_CLOSED;
}
}
} else {
error_code = NGHTTP2_PROTOCOL_ERROR;
/* This should be treated as stream error, but it results in lots
of RST_STREAM. So just ignore frame against nonexistent stream
for now. */
/* error_code = NGHTTP2_PROTOCOL_ERROR; */
}
if(error_code != 0) {
r = nghttp2_session_add_rst_stream(session, stream_id, error_code);

View File

@ -514,9 +514,11 @@ void test_nghttp2_session_recv_data(void)
CU_ASSERT(0 == ud.data_chunk_recv_cb_called);
CU_ASSERT(0 == ud.data_recv_cb_called);
item = nghttp2_session_get_next_ob_item(session);
CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(item));
/* DATA against nonexistent stream is ignored for now */
CU_ASSERT(NULL == item);
/* CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(item)); */
CU_ASSERT(0 == nghttp2_session_send(session));
/* CU_ASSERT(0 == nghttp2_session_send(session)); */
/* Create stream 1 with CLOSING state. DATA is ignored. */
stream = nghttp2_session_open_stream(session, 1,
@ -1212,8 +1214,10 @@ void test_nghttp2_session_on_data_received(void)
CU_ASSERT(0 == nghttp2_session_on_data_received(session, 4096,
NGHTTP2_FLAG_NONE, 6));
top = nghttp2_session_get_ob_pq_top(session);
CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(top));
CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == OB_CTRL(top)->rst_stream.error_code);
/* DATA against nonexistent stream is just ignored for now */
CU_ASSERT(top == NULL);
/* CU_ASSERT(NGHTTP2_RST_STREAM == OB_CTRL_TYPE(top)); */
/* CU_ASSERT(NGHTTP2_PROTOCOL_ERROR == OB_CTRL(top)->rst_stream.error_code); */
nghttp2_session_del(session);
}