Commit bbe4f5a3 authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa

Allow frame submission immediately after nghttp2_submit_{request,headers,pp}

This commit makes handling of outgoing HEADERS and PUSH_PROMISE in the
same priority of other frames on the stream, so these frames are
processed in the order they are submitted.  This allows application to
submit frames to a stream returned by nghttp2_submit_{request,
headers, push_promise} immediately.  The only exception is
WINDOW_UPDATA frame, which requires nghttp2_stream object, which is
not created yet.
parent 49a9ec2c
......@@ -2239,11 +2239,13 @@ int nghttp2_priority_spec_check_default(const nghttp2_priority_spec *pri_spec);
*
* .. warning::
*
* This function returns assigned stream ID if it succeeds. But
* that stream is not opened yet. The application must not submit
* frame to that stream ID before
* This function returns assigned stream ID if it succeeds and
* |stream_id| is -1. But that stream is not opened yet. The
* application must not submit WINDOW_UPDATE frame using
* `nghttp2_submit_window_update()` to that stream ID before
* :member:`nghttp2_session_callbacks.before_frame_send_callback` is
* called for this frame.
* called for this frame. Other types of frames can be submitted to
* the returned stream ID.
*
*/
int32_t nghttp2_submit_request(nghttp2_session *session,
......@@ -2367,9 +2369,11 @@ int nghttp2_submit_response(nghttp2_session *session,
*
* This function returns assigned stream ID if it succeeds and
* |stream_id| is -1. But that stream is not opened yet. The
* application must not submit frame to that stream ID before
* application must not submit WINDOW_UPDATE frame using
* `nghttp2_submit_window_update()` to that stream ID before
* :member:`nghttp2_session_callbacks.before_frame_send_callback` is
* called for this frame.
* called for this frame. Other types of frames can be submitted to
* the returned stream ID.
*
*/
int32_t nghttp2_submit_headers(nghttp2_session *session, uint8_t flags,
......@@ -2538,14 +2542,6 @@ int nghttp2_submit_settings(nghttp2_session *session, uint8_t flags,
* :enum:`NGHTTP2_ERR_INVALID_ARGUMENT`
* The |stream_id| is 0.
*
* .. warning::
*
* This function returns assigned promised stream ID if it succeeds.
* But that stream is not opened yet. The application must not
* submit frame to that stream ID before
* :member:`nghttp2_session_callbacks.before_frame_send_callback` is
* called for this frame.
*
*/
int32_t nghttp2_submit_push_promise(nghttp2_session *session, uint8_t flags,
int32_t stream_id,
......
......@@ -634,11 +634,6 @@ int nghttp2_session_add_frame(nghttp2_session *session,
stream = nghttp2_session_get_stream(session, frame->hd.stream_id);
switch(frame->hd.type) {
case NGHTTP2_HEADERS:
case NGHTTP2_PUSH_PROMISE:
item->weight = NGHTTP2_MAX_WEIGHT;
break;
case NGHTTP2_RST_STREAM:
if(stream) {
/* We rely on the stream state to decide whether number of
......
......@@ -4666,25 +4666,12 @@ void test_nghttp2_session_on_ctrl_not_send(void)
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(1 == user_data.frame_not_send_cb_called);
CU_ASSERT(NGHTTP2_HEADERS == user_data.not_sent_frame_type);
CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSED == user_data.not_sent_error);
CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSING == user_data.not_sent_error);
stream = nghttp2_session_open_stream(session, 3, NGHTTP2_STREAM_FLAG_NONE,
&pri_spec_default,
NGHTTP2_STREAM_OPENED, &user_data);
/* Check HEADERS */
user_data.frame_not_send_cb_called = 0;
/* Queue RST_STREAM */
CU_ASSERT(0 ==
nghttp2_submit_headers(session, NGHTTP2_FLAG_END_STREAM, 3,
NULL, NULL, 0, NULL));
CU_ASSERT(0 == nghttp2_submit_rst_stream(session, NGHTTP2_FLAG_NONE, 3,
NGHTTP2_INTERNAL_ERROR));
CU_ASSERT(0 == nghttp2_session_send(session));
CU_ASSERT(1 == user_data.frame_not_send_cb_called);
CU_ASSERT(NGHTTP2_HEADERS == user_data.not_sent_frame_type);
CU_ASSERT(NGHTTP2_ERR_STREAM_CLOSED == user_data.not_sent_error);
nghttp2_session_del(session);
/* Check request HEADERS */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment