Commit Graph

337 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa 1d138accb9 Unify DATA and other frames in nghttp2_outbound_item and save malloc() 2014-10-03 21:31:37 +09:00
Tatsuhiro Tsujikawa e20b417b84 Embed aux_data to nghttp2_outbound_item so that we can save some malloc() calls 2014-09-30 21:45:15 +09:00
Tatsuhiro Tsujikawa a11fbf6e2f Optimize connection level remote flow control
Previously when connection level remote flow control window gets 0, we
mark the stream having DATA frame with
NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL.  When connection level
WINDOW_UPDATE is received, we checks all existing streams, including
closed ones, and call nghttp2_stream_resume_deferred_data().  The
profiler shows this is expensive.

Now we prepare dedicated priority queue for DATA frames.  And we don't
mark stream with NGHTTP2_STREAM_FLAG_DEFERRED_FLOW_CONTROL when DATA
cannot be sent solely due to connection level flow control.  Instead,
we just queue DATA item to queue.  We won't pop DATA item from queue
when connection level remote window size is 0.  This way, we avoid the
expensive operation for all streams when WINDOW_UPDATE is arrived.
2014-09-26 00:01:51 +09:00
Tatsuhiro Tsujikawa 89c3c08590 tests: Fix compiler warning 2014-09-19 00:20:54 +09:00
Tatsuhiro Tsujikawa b2f88f8fe3 Fix memory leak around stream->data_item
Previously we missed the case where stream->data_item is not deleted
and it caused leak.  Now stream->data_item is properly deleted when
session is deleted.  We decided not to delete data_item in
nghttp2_stream_free() since we need nghttp2_session to decide whether
data_item should be deleted or not there.
2014-09-17 23:16:00 +09:00
Tatsuhiro Tsujikawa 901de5fbce Add nghttp2_option_set_recv_client_preface()
By default, nghttp2 library only handles HTTP/2 frames and does not
recognize first 24 bytes of client connection preface. This design
choice is done due to the fact that server may want to detect the
application protocol based on first few bytes on clear text
communication. But for simple servers which only speak HTTP/2, it is
easier for developers if nghttp2 library takes care of client
connection preface.

If this option is used with nonzero val, nghttp2 library checks first
24 bytes client connection preface. If it is not a valid one,
nghttp2_session_recv() and nghttp2_session_mem_recv() will return
error NGHTTP2_ERR_BAD_PREFACE, which is fatal error.
2014-09-13 19:50:44 +09:00
Tatsuhiro Tsujikawa 9b2c24ad68 tests: Remove debug output 2014-08-28 23:32:14 +09:00
Tatsuhiro Tsujikawa b4bb6a6101 Add reserved bits to header and frames
Currently reserved bit is always set to 0.  The addition of reserved
bit is for future extension.
2014-08-28 23:30:42 +09:00
Tatsuhiro Tsujikawa 4c11cd0671 Add test to submit DATA frame twice
This commit adds test to submit DATA frame twice and fixes the bug
that 2nd DATA is not sent.
2014-08-25 23:46:17 +09:00
Tatsuhiro Tsujikawa 4c5c6749a0 Check buffer capacity explicitly 2014-08-25 23:12:17 +09:00
Tatsuhiro Tsujikawa dd038bf753 Fix crash when buffer was reallocated after read_length_callback
Added test for this crash.
2014-08-25 23:05:39 +09:00
Tatsuhiro Tsujikawa 0b1ab90fb8 Move frame_type parameter in front of stream_id
This commit moves frame_type parameter of
nghttp2_data_soruce_read_length_callback in front of stream_id
parameter.  The motivation is that other callback is generally put
frame related parameters first.  To make it consistent, we move
frame_type, which is frame ralted parameter, to the left.
2014-08-25 22:31:11 +09:00
Tatsuhiro Tsujikawa 82bc7198e6 Change nghttp2_session_get_stream_remote_window_size behavior
Now it returns only stream's available remote window size, without
considering connection level window size.  For connection-level window
size, nghttp2_session_get_remote_window_size() is added by this
commit.  To get old behavior of
nghttp2_session_get_stream_remote_window_size() is use
min(nghttp2_session_get_stream_remote_window_size(),
nghttp2_session_get_remote_window_size()).  The reason of this change
is that it is desirable to know just stream level window size without
taking into connection level window size.  This is useful for
debugging purpose.
2014-08-25 21:44:22 +09:00
Tatsuhiro Tsujikawa a36c4c6f5f Add nghttp2_on_begin_frame_callback
nghttp2_on_begin_frame_callback will be invoked when a frame header is
received.
2014-08-25 21:26:50 +09:00
Tatsuhiro Tsujikawa 3655090997 Merge branch 'window_size_control' of https://github.com/akamai/nghttp2 into akamai-window_size_control 2014-08-25 21:09:26 +09:00
Scott Mitchell 3cd08251ca Send window size API extension
Motivation:

The send window size is currently fixed by a macro at compile time.
In order for users of the library to impact the send window size they
would have to change a macro at compile time. The window size may be dynamic
depending on the environment and deployment scheme. The library users
currently have no way to change this parameter.

Modifications:

Add a new optional callback method which is called before data is sent to
obtain the desired send window size. The callback return value will be
subject to a range check for the current session, stream, and settings
limits defined by flow control.

Result:
Library users have control over their send sizes.
2014-08-24 11:32:44 -04:00
Tatsuhiro Tsujikawa bf48ef9bab Add test to check consumed size when no auto window update is enabled 2014-08-24 22:36:35 +09:00
Tatsuhiro Tsujikawa 7bfa276e96 Fix bug that NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE causes session failure
Previously returning NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE from
on_header_callback moves input offset badly and it causes header
decompression error on the subsequent frames.  This commit fix this
bug.
2014-08-24 00:50:55 +09:00
Tatsuhiro Tsujikawa bbe4f5a3d1 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.
2014-08-17 17:31:43 +09:00
Tatsuhiro Tsujikawa b8a2bf2675 Remove END_SEGMENT flag 2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 98be65a1eb Allow submission of unknown SETTINGS 2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 77374ac6e2 Implement SETTINGS_MAX_FRAME_SIZE and SETTINGS_MAX_HEADER_LIST_SIZE 2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 079db14d45 Add nghttp2_session_consume() API
Reworked no automatic WINDOW_UPDATE feature.  We added new API
nghttp2_session_consume() which tells the library how many bytes are
consumed by the application.  Instead of submitting WINDOW_UPDATE by
the application, the library is now responsible to submit
WINDOW_UPDATE based on consumed bytes.  This is more reliable method,
since it enables us to properly send WINDOW_UPDATE for stream and
connection individually.  The previous implementation of nghttpx had
broken connection window management.
2014-07-31 23:05:53 +09:00
Tatsuhiro Tsujikawa 38bfbffb1b Remove HPACK reference set 2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa 63398f30dd Extend frame length field to 24 bits 2014-07-31 23:05:52 +09:00
Tatsuhiro Tsujikawa 55c697e9f4 Handle multiple SETTINGS_HEADER_TABLE_SIZE in incoming SETTINGS frame
Previously we just assumed that if same settings ID is found in
SETTINGS, it is enough to process last seen entry.  But it turns out
it is not enough for SETTINGS_HEADER_TABLE_SIZE.  If we have 0 and
4096 for SETTINGS_HEADER_TABLE_SIZE in one SETTINGS, we must first
shrink dynamic table to 0 and then enlarge it to 4096.  This means
that we have to remember the minimum value and last value.
2014-07-15 00:25:31 +09:00
Tatsuhiro Tsujikawa e5abc475f1 Don't send more than NGHTTP2_MAX_HEADERSLEN bytes header block 2014-07-02 22:45:38 +09:00
Tatsuhiro Tsujikawa 8e0fcd3922 Add test for graceful shutdown use case 2014-06-18 12:08:12 +09:00
Tatsuhiro Tsujikawa b78a51da0e Support graceful shutdown using multiple GOAWAY
Add last_stream_id parameter to nghttp2_submit_goaway().  To terminate
connection immediately with application chosen last stream ID,
nghttp2_session_terminate_session2() was added.
2014-06-18 11:35:08 +09:00
Tatsuhiro Tsujikawa 9b174bf5c9 Fix compile error with -Wshorten-64-to-32
The original patch was contributed by Alexis La Goutte
2014-06-11 23:37:16 +09:00
Tatsuhiro Tsujikawa 2878e1e258 Refactor storage of settings
Now local and remote settings values are stored in dedicated structure
nghttp2_settings_storage.
2014-06-10 21:29:19 +09:00
Tatsuhiro Tsujikawa dacc9b2f1c Separate extension frames from core frames
ALTSVC and BLOCKED frames are now extension frames.  To add new
extension frame without modifying nghttp2_frame union, which causes so
name bump, we separated extension frames from core frames.
nghttp2_frame includes generic nghttp2_extension.  The payload member
of nghttp2_extension will point to the structure of extension frame
payload.  The frame types of extension frames are defined in
nghttp2_ext_frame_type.
2014-06-09 23:16:54 +09:00
Tatsuhiro Tsujikawa c46d3dafc6 Remove PAD_HIGH and Pad High field
CONTINUATION now doesn't have padding.
2014-06-07 18:15:36 +09:00
Tatsuhiro Tsujikawa 458ccb3681 Ignore unknown frame types
Unexpected CONTINUATION frame is handled separately as connection
error.
2014-06-07 16:30:55 +09:00
Tatsuhiro Tsujikawa 3db8935e20 Remove per-frame compression 2014-06-07 16:04:43 +09:00
Tatsuhiro Tsujikawa d113055899 nghttp2_hd: Use single buffer for an name/value pair
Previously we use 2 separate buffer for each name and value.  The
problem is we would waste buffer space for name because it is usually
small.  Also tuning buffer size for each buffer separately is not
elegant and current HTTP server practice is that one buffer for 1
name/value pair.  This commit unifies 2 buffers into 1.
2014-05-28 23:33:37 +09:00
Tatsuhiro Tsujikawa 3e3d51842b Interleave stream DATA more naturally
We simulate resource sharing by decreasing weight.  The thing is if
weight is wrapped, that item continues to send DATA until its weight
gets lowered under the other items.  This commits fix this issue.
2014-05-08 23:07:29 +09:00
Tatsuhiro Tsujikawa e8de437d5c Return new stream ID from nghttp2_submit_{request, headers, push_promise}
Previously stream ID was assigned just before HEADERS or PUSH_PROMISE
was serialized and nghttp2_submit_{request, headers, push_promise} did
not return stream ID.  The application has to check assigned stream ID
using before_frame_send_callback.  Now it is apparent that priority is
meant to DATA transfer only.  Also application can reorder the
requests if it wants. Therefore we can assign stream ID in
nghttp2_submit_* functions and return stream ID from them.  With this
change, now application does not have to check stream ID using
before_frame_send_callback and its code will be simplified.
2014-05-07 23:24:07 +09:00
Tatsuhiro Tsujikawa 052be3296c Implement compressed DATA
The library interface supports compressed DATA.  The library does not
deflate nor inflate data payload.  When sending data, an application
has to compress data and set NGHTTP2_DATA_FLAG_COMPRESSED to
data_flags parameter in nghttp2_data_source_read_callback.  On
receiving, flags parameter in nghttp2_on_data_chunk_recv_callback
includes NGHTTP2_FLAG_COMPRESSED.  An application should check the
flags and inflate data as necessary.  Since compression context is per
frame, when DATA is seen in nghttp2_on_frame_recv_callback, an
application should reset compression context.
2014-04-25 01:27:18 +09:00
Tatsuhiro Tsujikawa ee26469cd9 Handle circular dependency
Handle the situation if a stream is told to depend on its descendant.
This is what
http://tools.ietf.org/html/draft-ietf-httpbis-http2-12#section-5.3.3
says.
2014-04-24 23:44:34 +09:00
Tatsuhiro Tsujikawa 853c9888d9 Distribute effective weight among only streams with marked as top
If stream with dpri value of no_data, we check any its descendant has
stream with dpri value of top.  If so, we have to distribute of its
portion of weight to its descendants.
2014-04-24 23:37:40 +09:00
Tatsuhiro Tsujikawa 1c1843297c priority: Add tests 2014-04-17 21:34:44 +09:00
Tatsuhiro Tsujikawa aa4d43f31e Allow exclusive dependency to stream 0 2014-04-17 21:18:18 +09:00
Tatsuhiro Tsujikawa ac86b51e37 Implement simplified dependency based priority 2014-04-15 22:55:07 +09:00
Tatsuhiro Tsujikawa ece6521d26 Check stream availability when sending ALTSVC with stream_id != 0 2014-04-10 23:27:10 +09:00
Tatsuhiro Tsujikawa 9b3d5a8be5 Harden check for submit functions
nghttp2_submit_{headers,request}: Return NGHTTP2_ERR_INVAILD_ARGUMENT
if pri_spec->type is invalid.

nghttp2_submit_push_promise: Return NGHTTP2_ERR_PROTO if issued by
client.

nghttp2_submit_altsvc: Return NGHTTP2_ERR_PROTO instead of
NGHTTP2_ERR_INVALID_STATE if issued by client.
2014-04-09 00:13:11 +09:00
Tatsuhiro Tsujikawa 8f23c0c38b Name unnamed union in nghttp2_priority_spec so that we can be C90 compatible 2014-04-05 18:40:44 +09:00
Tatsuhiro Tsujikawa e7ad3633c7 nghttp2_data_source_read_callback: Replace eof with uint32_t *data_flags
Replace int *eof with uint32_t *data_flags so that we can easily
extend functionality if we have to (but we don't do if possible).
2014-04-05 17:59:24 +09:00
Tatsuhiro Tsujikawa a0d93e7744 Fix unit test 2014-04-05 17:55:14 +09:00
Tatsuhiro Tsujikawa 1e38ceb1cd Allow empty SETTINGS in upgrade 2014-04-04 20:23:46 +09:00
Tatsuhiro Tsujikawa ac2a8ef4a2 Fix bug that transfer stuck when stream marked as top is deferred 2014-04-03 15:48:51 +09:00
Tatsuhiro Tsujikawa ef40879b5f Refactor nghttp2_stream
Combine deferred_data and data into data_item and merge deferred_flags
into flags.
2014-04-02 22:55:49 +09:00
Tatsuhiro Tsujikawa 2685e3405f Rename NGHTTP2_DATA_PAYLOAD_LENGTH as NGHTTP2_DATA_PAYLOADLEN 2014-04-02 20:35:07 +09:00
Tatsuhiro Tsujikawa 9c4c99bf96 Adjust transmission frame buffer size to support maximum payload size 2014-04-02 20:33:01 +09:00
Tatsuhiro Tsujikawa c9f90924a9 Add flags parameter to nghttp2_on_header_callback 2014-04-02 02:10:35 +09:00
Tatsuhiro Tsujikawa 7877b676e3 Honor NGHTTP2_NV_FLAG_NO_INDEX in deflater and inflater 2014-04-02 01:25:44 +09:00
Tatsuhiro Tsujikawa f785e56dba Implement ALTSVC frame 2014-04-01 21:47:51 +09:00
Tatsuhiro Tsujikawa b85e2ab7f7 Share stream_group weight among streams marked as top 2014-03-31 22:51:33 +09:00
Tatsuhiro Tsujikawa ab2dc5967d Replace HTTP/2.0 with HTTP/2 2014-03-30 19:26:37 +09:00
Tatsuhiro Tsujikawa 21d5986157 Fail nghttp2_submit_settings if there is pending SETTINGS frame in-flight
pending_local_max_concurrent_stream is now set in
nghttp2_session_add_settings, rather than after frame was sent.
2014-03-30 18:07:52 +09:00
Tatsuhiro Tsujikawa 74daa16a1c Retain incoming closed streams for dependency tree
The number of closed stream to keep is limited by
MAX_CONCURRENT_STREAMS - current active stream.
2014-03-30 17:41:54 +09:00
Tatsuhiro Tsujikawa f7162ab702 Implement dependency based priority 2014-03-30 01:24:16 +09:00
Tatsuhiro Tsujikawa 01586f473d Wrap small inbound buffer by nghttp_buf 2014-03-22 18:27:38 +09:00
Tatsuhiro Tsujikawa 68b392817b nghttp2_bufs: Add chunk_keep to specify the number of buffers to keep on reset 2014-03-16 21:38:13 +09:00
Tatsuhiro Tsujikawa b464cb78ac Fix tests to reflect their intent 2014-03-14 00:25:43 +09:00
Tatsuhiro Tsujikawa 1be8d1b797 inflate_header_block: Issue RST_STREAM if header decompression failed 2014-03-13 23:02:33 +09:00
Tatsuhiro Tsujikawa d07bb1ddff Rework outbound frame buffers 2014-03-13 22:11:02 +09:00
Tatsuhiro Tsujikawa 74f899fc01 Replace NGHTTP2_MAX_FRAME_LENGTH with NGHTTP2_MAX_PAYLOADLEN 2014-03-11 02:01:08 +09:00
Tatsuhiro Tsujikawa e803c6b65e Replace NGHTTP2_FRAME_HEAD_LENGTH with NGHTTP2_FRAME_HDLEN 2014-03-11 01:55:42 +09:00
Tatsuhiro Tsujikawa 358b4386d3 Introduce nghttp2_buf to ease buffer management 2014-03-11 01:47:38 +09:00
Tatsuhiro Tsujikawa 54dab50015 Support END_SEGMENT in nghttp2_submit_data() 2014-03-06 00:19:02 +09:00
Tatsuhiro Tsujikawa 547d6d1fb5 Use 4086 as max DATA payload size to make DATA frame fit into 4K buffer 2014-03-05 22:48:17 +09:00
Tatsuhiro Tsujikawa d1c1deaf03 Add promised_stream_user_data parameter to nghttp2_submit_push_promise
This is very useful to associate application specific data to promised
stream.

nghttp2_nv_array_copy now does not complain the header field is large.
2014-02-25 00:26:12 +09:00
Tatsuhiro Tsujikawa fc25143418 Remove END_PUSH_PROMISE in favor of END_HEADERS 2014-02-21 21:23:51 +09:00
Tatsuhiro Tsujikawa 3395f7158f Strict handling of max concurrent streams
Exceeding ACKed max concurrent streams results in connection error.
This change fixes the bug that num_{incoming,outgoing}_streams
is decremented wrongly if a stream is in reserved state and
RST_STREAM is send and its state is changed to NGHTTP2_STREAM_CLOSING.
This change also fixes the bug that transmission of push response
HEADERS does not increase num_outgoing_streams.
2014-02-20 23:10:32 +09:00
Tatsuhiro Tsujikawa 2966ad2d15 Update doc 2014-02-19 00:16:25 +09:00
Tatsuhiro Tsujikawa 3f3f258cd6 Add padding to PUSH_PROMISE 2014-02-15 16:30:43 +09:00
Tatsuhiro Tsujikawa 1e95c8b313 Allow always max 1024 padding for HEADERS
We need paddings regardless of payload and frame boundary to mitigate
certain attacks.

Since we handles CONTINUATION internally, we don't show FLAG_PAD_HIGH
and PAD_LOW flags of HEADERS in nghttp/nghttpd. We just show the
total paddings in HEADERS + CONTINUATION.
2014-02-15 01:34:04 +09:00
Tatsuhiro Tsujikawa 7ab4206269 Tear down connection if SETTINGS makes window size overflow 2014-02-14 16:08:39 +09:00
Tatsuhiro Tsujikawa fd88c6160d HPACK post -05 updates
* Use 1 Huffman code table for both request and response
* Remove complicated deflater side table size management
* Add encoding context update
* Fix memory leak in inflater
2014-02-13 23:22:52 +09:00
Tatsuhiro Tsujikawa c7a17093cb Fix compile errors with --enable-maintainer-mode 2014-02-11 21:39:35 +09:00
Tatsuhiro Tsujikawa 067a4d05c3 Merge branch 'master' into draft-10 2014-02-11 21:33:49 +09:00
Tatsuhiro Tsujikawa d3fb352c0e Fix invalid memory use 2014-02-11 21:33:22 +09:00
Tatsuhiro Tsujikawa 7822bbd7e8 Fix PAD_HIGH and PAD_LOW are not counted in flow control 2014-02-11 21:30:44 +09:00
Tatsuhiro Tsujikawa 109b8cedde Fix compile error and test failures 2014-02-11 16:12:26 +09:00
Tatsuhiro Tsujikawa e78a2100ec Merge branch 'master' into draft-10 2014-02-11 16:03:42 +09:00
Tatsuhiro Tsujikawa cacf4ecf26 Fix premature header block is not treated as connection error 2014-02-11 16:00:59 +09:00
Tatsuhiro Tsujikawa cbbecfeb41 Fix broken session_detect_idle_stream() 2014-02-11 15:35:44 +09:00
Tatsuhiro Tsujikawa 78d202ac30 Callback based padding from application
Now previous padding options are removed and instead we added
select_padding_callback to select padding length for each frame
by application. If this callback is not implemented by application,
no padding is added.

This change also fixes the broken session_detect_idle_stream()
if stream_id is our side.
2014-02-11 15:28:44 +09:00
Tatsuhiro Tsujikawa 68b5ffc1dc Rename padding related names 2014-02-09 21:46:15 +09:00
Tatsuhiro Tsujikawa 909b79e69b Fix test 2014-02-09 18:33:27 +09:00
Tatsuhiro Tsujikawa 1db2195389 Implement padding for HEADERS and CONTINUATION 2014-02-09 15:17:26 +09:00
Tatsuhiro Tsujikawa 814d0f76f3 Implement DATA frame padding 2014-02-08 00:23:18 +09:00
Tatsuhiro Tsujikawa f26270b5b4 Change SETTINGS payload format according to the spec 2014-02-06 22:06:42 +09:00
Tatsuhiro Tsujikawa f2c654f898 Fix reception of ENABLE_PUSH ignored; strict check for SETTINGS value 2014-02-06 21:39:58 +09:00
Tatsuhiro Tsujikawa c79adf6997 Remove flow control disabling feature 2014-02-06 00:23:20 +09:00
Tatsuhiro Tsujikawa 08ff95d402 Detect frame reception for idle stream and make it connection error
Only stream ID which larger than currently used stream ID is
detected as idle.
2014-02-01 17:03:55 +09:00
Tatsuhiro Tsujikawa ab684a9f30 Remove nghttp2_on_request_recv_callback
It is easy enough to check the end of incoming data by evaluating
frame->hd.flags & NGHTTP2_FLAG_END_STREAM in on_frame_recv_callback
2014-01-29 21:56:01 +09:00
Tatsuhiro Tsujikawa e186e01933 Replace on_end_headers_callback with on_begin_headers_callback
Previously, there is inconsistency when on_frame_recv_callback
is called between HEADERS/PUSH_PROMISE and the other frames.
For former case, it is called before header block, in latter
case, it is called after whole frame is received. To make it
consistent, we call on_frame_recv_callback for HEADERS/PUSH_PROMISE
after its frame is fully received. Since on_frame_recv_callback
can signal the end of header block, we replaced on_end_headers_callback
with on_begin_headers_callback, which is called when the reception
of the header block is started.
2014-01-29 21:23:13 +09:00
Tatsuhiro Tsujikawa a3082b7c1e Remove nghttp2_on_data_recv_callback and nghttp2_on_data_send_callback
nghttp2_data is added to nghttp2_frame union. When DATA is
received, nghttp2_on_frame_recv_callback is called. When DATA is
sent, nghttp2_on_frame_send_callback is called.
2014-01-27 22:16:05 +09:00
Tatsuhiro Tsujikawa fc07a62337 Rename nghttp2_data as nghttp2_private_data
This is a preparation to add public nghttp2_data struct to
nghttp2_frame union.
2014-01-27 21:22:33 +09:00
Tatsuhiro Tsujikawa 9314e30987 Support transmission of CONTINUATION, change nghttp2_frame_hd
The maximum frame size including header block is still limited
to NGHTTP2_HD_MAX_BUFFER_LENGTH, which is 32KB.
2014-01-26 23:10:33 +09:00
Tatsuhiro Tsujikawa 91401cfe26 Support CONTINUATION frame reception 2014-01-26 20:31:28 +09:00
Tatsuhiro Tsujikawa e7fc2951b8 nghttp2_hd: Define dedicated struct for HPACK deflater and inflater 2014-01-26 17:53:04 +09:00
Tatsuhiro Tsujikawa 45a9f0b637 Remove nghttp2_frame_unpack_* functions 2014-01-26 16:46:18 +09:00
Tatsuhiro Tsujikawa dba2406aba nghttp2_sesson_mem_recv: Process incoming data in streaming fashion
Now incoming data is processed in very small buffer (up to 8 bytes)
using state machine. GOAWAY debug data can get to 16K - 1, and we
don't have callback for it. Since we don't want to buffer that
amount of data just for debugging, we currently discard it.
This change also makes parse_error callback not function.
It probably be removed from API.
2014-01-26 15:44:43 +09:00
Tatsuhiro Tsujikawa 2222b5ab0d Don't return NGHTTP2_ERR_STREAM_CLOSED when submitting DATA, PRIORITY, WU
Remove the check to see that stream exists at the time when submitting
DATA, PRIORITY and WINDOW_UPDATE. We will do this check when we actually
serialize and send them off to the network (or application provided
buffer).
2014-01-18 16:19:28 +09:00
Tatsuhiro Tsujikawa 22a4e3eab8 Remove nghttp2_session_continue
nghttp2_session_continue is removed. Now just call
nghttp2_session_mem_recv to continue after NGHTTP2_ERR_PAUSE.
2014-01-17 22:52:30 +09:00
Tatsuhiro Tsujikawa 5d535766bf inflate_header_block: Terminate session on compression error
Code cleanup is done as well
2014-01-17 10:13:33 +09:00
Tatsuhiro Tsujikawa 707a0b4103 Move name/value validation functions to src
nghttp2 library itself now accept octet header/value pairs,
completely not restricted by HTTP/1 header name/value rule.
The applications may impose restriction about them using
validators.
2014-01-17 02:16:53 +09:00
Tatsuhiro Tsujikawa 0e4b3d435e Emit header name/value pair using callback functions
Now, in nghttp2_on_frame_recv_callback, nva and nvlen in
HEADERS and PUSH_PROMISE frames are always NULL and 0 respectively.
The header name/value pairs are emitted successive
nghttp2_on_header_callback functions. The end of header fields are
signaled with nghttp2_on_end_headers_callback function.

Since NGHTTP2_ERR_PAUSE for nghttp2_on_frame_recv_callback is
introduced to handle header block, it is now deprecated.
Instead, nghttp2_on_header_callback can be paused using
NGHTTP2_ERR_PAUSE.
2014-01-17 01:49:43 +09:00
Tatsuhiro Tsujikawa a85a11c1d9 Update priority for the stream to get response only 2014-01-09 23:30:45 +09:00
Tatsuhiro Tsujikawa 5aa487c5ba nghttp2_stream: flags is now nghttp2_stream_flags
We use this flag to know whether it is pushed or not
2014-01-09 23:01:02 +09:00
Tatsuhiro Tsujikawa 45837a2cfa Ensure PRIORITY frame reception/transmission rule 2014-01-09 22:06:38 +09:00
Tatsuhiro Tsujikawa dfcdea894b Move header name/value pair validation to on_*_received functions 2013-12-25 23:38:55 +09:00
Tatsuhiro Tsujikawa 41104f7b63 Abandon DATA frame priority adjustment (again)
We tried several times about this subject, but for the current
HTTP/2.0 priority scheme, we think it is best to serve the highest
priroty streams first (interleaving streams if there are several
higest ones). There are an issue when aggregating several frontend
connections to one connection in backend, but it is HTTP/2.0
spec issue, rather than implementation.
2013-12-14 17:02:59 +09:00
Tatsuhiro Tsujikawa 6c77cec270 Remove nghttp2_submit_* API functions which has char **nv parameter
The nghttp2_submit_{request,response}2 functions are renamed as
nghttp2_submit_{request, response}.
2013-12-08 21:39:43 +09:00
Tatsuhiro Tsujikawa 1dea4e154b Reintroduce priority adjustment for DATA frame
This mechanism existed but was deleted. We bring it back in order to
prevent lower priority streams from starving.
2013-12-05 23:12:18 +09:00
Tatsuhiro Tsujikawa 40a666e7d1 Add nghttp2_submit_response2 tests 2013-11-28 21:47:10 +09:00
Tatsuhiro Tsujikawa 2ae788eddd Replace nghttp2_set_option with nghttp2_session_{client,server}_new2
nghttp2_session_client_new2 and nghttp2_session_server_new2 take
additional parameters which specifies session options.
nghttp2_set_option is somewhat crumsy because of type checking.
Now we use nghttp2_opt_set, which specifies individual options with
types. We changed the value of nghttp2_opt, so this change will
require re-compile.
2013-11-08 00:12:39 +09:00
Tatsuhiro Tsujikawa 7b3dade184 tests: Fix memory leak 2013-11-02 16:55:58 +09:00
Tatsuhiro Tsujikawa 4bc44b0c0b Implement SETTINGS_ENABLE_PUSH
It is not clear that SETTINGS_ENABLE_PUSH = 0 disallows HEADERS
to the reserved streams. For now, we just check the reception
and transmission of PUSH_PROMISE against SETTINGS_ENABLE_PUSH.
2013-11-02 16:53:06 +09:00
Tatsuhiro Tsujikawa ad64f11a95 Remove code submitting WINDOW_UPDATE with negative delta
It is effectively dead code because we should have already submit
WINDOW_UPDATE before this case happens.
2013-10-30 23:43:40 +09:00
Tatsuhiro Tsujikawa 2e7bc014e1 Return 0 if recv_window_size is negative; add tests 2013-10-30 01:58:38 +09:00
Tatsuhiro Tsujikawa 2dd44746a6 Merge branch 'master' into hpack-exp 2013-10-28 23:15:14 +09:00
Tatsuhiro Tsujikawa a416891454 tests: Fix test error on 32-bit system 2013-10-28 22:00:49 +09:00
Tatsuhiro Tsujikawa 924c858c8f tests: Add SETTINGS_HEADER_TABLE_SIZE test case 2013-10-28 01:08:09 +09:00
Tatsuhiro Tsujikawa 8c530f36cb Include std lib headers before cunit header file 2013-10-27 23:20:44 +09:00
Tatsuhiro Tsujikawa 67ce60544e Change maximum frame length to 16383 2013-10-27 21:17:09 +09:00
Tatsuhiro Tsujikawa cfb9857f27 Use FRAME_SIZE_ERROR for invalid payload length 2013-10-27 20:55:44 +09:00
Tatsuhiro Tsujikawa 5ace898392 Update error code 2013-10-27 19:31:24 +09:00
Tatsuhiro Tsujikawa a46ccdb144 Apply initiated SETTINGS changes on reception of ACK 2013-10-27 19:22:51 +09:00
Tatsuhiro Tsujikawa 8f8c841df0 Merge branch 'master' into hpack-exp 2013-10-25 22:51:51 +09:00
Tatsuhiro Tsujikawa 896db5b24f API change: Add flags parameter to all submit_* functions
The nghttp2_submit_{request,response} family do not get this change.
2013-10-25 22:50:24 +09:00
Tatsuhiro Tsujikawa 9e50ae46d9 nghttp_hd: Use NGHTTP2_HD_SIDE_{REQUEST,RESPONSE} instead of {CLIENT,SERVER}
This change conveys better notion about compression context.
2013-10-21 00:44:39 +09:00
Tatsuhiro Tsujikawa 4e4fab01b1 Merge branch 'master' into hpack-exp
Conflicts:
	lib/nghttp2_hd.c
2013-10-18 20:06:36 +09:00
Tatsuhiro Tsujikawa 0efa6e657f Fix outbound flow control count
We wrongly added the whole payload length even if we sent part of it.
2013-10-18 19:43:59 +09:00
Tatsuhiro Tsujikawa 50cdcca911 Implement static Huffman for header compression
The current implementation uses Huffman code tables described
in http://tools.ietf.org/html/draft-rpeon-httpbis-header-compression-03
2013-10-15 23:55:12 +09:00
Tatsuhiro Tsujikawa e85418f045 Fix local window size adjustments
Now shrinking local window size properly limits the amount of
WINDOW_UPDATE value so that shrinked window is honored.
2013-10-12 17:02:37 +09:00
Tatsuhiro Tsujikawa c5501dcb8d tests: Test WINDOW_UPDATE is queued when certain amount of DATA is received 2013-10-04 21:42:02 +09:00
Tatsuhiro Tsujikawa 21d76dcc75 Add nghttp2_session_continue API function
The NGHTTP2_ERR_PAUSE library error code is introduced to pause
the execution of nghttp2_session_mem_recv() when that error code
is returned from nghttp2_on_frame_recv_callback or
nghttp2_on_data_chunk_recv_callback. If this happens, the parameters
available for both callbacks are retained until the application
calls nghttp2_session_continue(). The application must retain
input bytes which was used to produce the frame.
After successful call of nghttp2_session_continue, the application
can continue to call nghttp2_session_mem_recv() to process
additional data.
2013-09-28 17:59:24 +09:00
Tatsuhiro Tsujikawa 99ba622fed Add NGHTTP2_OPT_PEER_MAX_CONCURRENT_STREAMS option
And utilize it in nghttp to limit initial max concurrent streams.
2013-09-14 19:41:49 +09:00
Tatsuhiro Tsujikawa 94263216fb Add nghttp2_submit_request2
This function is similar to nghttp2_submit_request and the
difference is it takes an array of nghttp2_nv as name/value pairs.
It is useful if name/value pairs is not NULL-terminated in the
application code.
2013-09-11 00:55:35 +09:00
Daniel Stenberg a1c3f89c72 nghttp2_pack_settings_payload: added a buffer size argument
To make it less likely that a user gets a buffer overflow if a
too small buffer is used.
2013-09-09 21:22:27 +09:00
Tatsuhiro Tsujikawa a67d042a00 tests: Fix buffer overrun 2013-09-08 15:29:46 +09:00
Tatsuhiro Tsujikawa d960cf8953 Add const to read-only nghttp2_frame* parameter in callbacks 2013-09-03 21:24:14 +09:00
Tatsuhiro Tsujikawa 053c444769 Add int return value to nghttp2_on_request_recv_callback 2013-08-29 23:03:21 +09:00
Tatsuhiro Tsujikawa 81653c1d1b Add int return value to nghttp2_on_stream_close_callback 2013-08-29 22:58:05 +09:00
Tatsuhiro Tsujikawa b9d2f9b6b0 Add int return value to on_frame_not_send_callback 2013-08-29 21:51:58 +09:00
Tatsuhiro Tsujikawa d4852b0f11 Add int return value to on_frame_send_callback 2013-08-29 21:48:34 +09:00
Tatsuhiro Tsujikawa 544ac9f61f Add int return value to nghttp2_on_data_recv_callback 2013-08-29 21:41:33 +09:00
Tatsuhiro Tsujikawa 972b47d6af Add int return value to nghttp2_on_data_chunk_recv_callback 2013-08-29 21:39:32 +09:00
Tatsuhiro Tsujikawa fb7d22fcb9 Add int return value to nghttp2_on_invalid_frame_recv_callback 2013-08-29 21:37:26 +09:00
Tatsuhiro Tsujikawa a59cd3be82 Add int return value to nghttp2_on_frame_recv_callback 2013-08-29 21:33:52 +09:00
Tatsuhiro Tsujikawa b37f99ca03 Connection error if payload size is strictly greater than (1 << 14) - 1
It would be desired to add option to make this limit configurable.
Fix scripted_recv_callback in tests.
2013-08-28 02:13:57 +09:00
Tatsuhiro Tsujikawa 82b9f78fc7 Check incoming header field name strictly
The validation rule is described in
http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-02#section-4.1.2
2013-08-25 17:39:29 +09:00
Tatsuhiro Tsujikawa 2d41c99289 Connection error if header continuation is employed by peer for now 2013-08-24 19:28:57 +09:00
Tatsuhiro Tsujikawa 35229b250f Treat reception of DATA in reserved stream as connection error 2013-08-23 03:33:05 +09:00
Tatsuhiro Tsujikawa da384988cd Add test for WINDOW_UPDATE against reserved 2013-08-23 03:33:05 +09:00
Tatsuhiro Tsujikawa e278efdf38 Strict handling of connection error
Following cases are now treated as connection error of type
PROTOCOL_ERROR.

* Receiving HEADERS from client in reserved (local)
* Receiving PUSH_PROMISE against peer-initiated stream
* Receiving WINDOW_UPDATE against in reserved (local, remote)
2013-08-23 03:33:05 +09:00
Tatsuhiro Tsujikawa 0c9703fa2c Remove NGHTTP2_FLAG_END_FLOW_CONTROL 2013-08-23 03:33:05 +09:00
Tatsuhiro Tsujikawa b1ae1c30d8 Allow duplicate settings ID in SETTINGS
If multiple same ID are found, use the last one.
2013-08-23 03:33:05 +09:00
Tatsuhiro Tsujikawa a52ca391a2 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.
2013-08-10 15:13:53 +09:00
Tatsuhiro Tsujikawa 6ed8a8957b Early termination if stream is not found
Add this check in nghttp2_submit_{priority, window_update, data,
push_promise}.
2013-08-10 00:02:24 +09:00
Tatsuhiro Tsujikawa 1155606d5e Rewrite re-prioritization with PRIORITY 2013-08-09 23:40:41 +09:00
Tatsuhiro Tsujikawa a3ff4cb50b Rename window_size member of nghttp2_session as remote_window_size 2013-08-09 01:31:15 +09:00
Tatsuhiro Tsujikawa 19377fb3cd Allow disabling auto WINDOW_UPDATE for connection and stream individually
Now NGHTTP2_OPT_NO_AUTO_WINDOW_UPDATE is split into 2 options:
NGHTTP2_OPT_NO_AUTO_STREAM_WINDOW_UPDATE and
NGHTTP2_OPT_NO_AUTO_CONNECTION_WINDOW_UPDATE.
This is preparation for the upcoming removal of END_FLOW_CONTROL
flag. For nghttpx, instead of using END_FLOW_CONTROL to disable
connection-level flow control, increase window size by large
enough value, which is friendly way to current chromium
implementation.
2013-08-09 01:23:39 +09:00
Tatsuhiro Tsujikawa b979d2e8d2 Support increment/reduction of local window size by WINDOW_UPDATE 2013-08-09 00:58:52 +09:00
Tatsuhiro Tsujikawa e67096fef3 Handle overflow in initial window update in stream
Rename window_size in nghttp2_stream as remote_window_size.
2013-08-08 21:12:49 +09:00
Tatsuhiro Tsujikawa dcfa421d6f Fix connection-level flow control (local)
Fix the bug that connection-level local window is not updated
for the data is the last part of the stream. For the stream
level window may ignore this, connection-level window must
be updated. Also this change fixes the bug that connection-level
window is not updated for the ignored DATA frames.
2013-08-07 22:02:30 +09:00
Tatsuhiro Tsujikawa 73563de8d4 Specify max length for header value and header block
The max length of header block is not used right now. It will
be used when header continuation is implemented.
2013-08-06 21:57:26 +09:00
Tatsuhiro Tsujikawa 737ac01d91 Add API for HTTP Upgrade 2013-08-03 18:05:14 +09:00
Tatsuhiro Tsujikawa 8033152e80 Disable local flow control on FLOW_CONTROL_OPTIONS = 1 2013-07-28 19:05:51 +09:00
Tatsuhiro Tsujikawa 608a493925 Change initial window size to 65535 2013-07-27 21:26:47 +09:00
Tatsuhiro Tsujikawa ddd04e8ced Fix header compression bug, and perform always incremental indexing 2013-07-27 00:58:38 +09:00
Tatsuhiro Tsujikawa 1056d8690e Rename functions related to HEADERS 2013-07-25 21:07:38 +09:00
Tatsuhiro Tsujikawa 84cbebf4f7 Implement server push 2013-07-25 01:59:48 +09:00
Tatsuhiro Tsujikawa b7ff05c4c6 Fail session if header compression failed on send 2013-07-23 22:47:15 +09:00
Tatsuhiro Tsujikawa 0bcf90d32d Support PRIORITY frame send and receive 2013-07-23 00:28:00 +09:00
Tatsuhiro Tsujikawa aa4df35a10 Remove NGHTTP2_OPT_MAX_RECV_CTRL_FRAME_BUFFER option 2013-07-20 00:24:25 +09:00
Tatsuhiro Tsujikawa 61bf7c6b02 Integrate new header compression 2013-07-20 00:08:14 +09:00
Tatsuhiro Tsujikawa a3bdda68f8 End flow control by WINDOW_UPDATE 2013-07-16 21:30:36 +09:00
Tatsuhiro Tsujikawa d54cfb88ff Add connection-level flow control 2013-07-16 20:54:24 +09:00
Tatsuhiro Tsujikawa 1fdaa7e59a Disable flow control entirely with FLOW_CONTROL_OPTIONS 2013-07-16 18:26:57 +09:00
Tatsuhiro Tsujikawa 24cab312cf Make spdycat and spdyd barely work 2013-07-16 00:15:04 +09:00
Tatsuhiro Tsujikawa 48cb017245 Implement HTTP-draft-04/2.0 2013-07-15 21:45:59 +09:00
Tatsuhiro Tsujikawa 0edce70343 Rebranding nghttp2 2013-07-13 00:43:06 +09:00