Commit Graph

529 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa bef3d47c16 Rename functions and nghttp2_debug.h to move debug macro there 2016-10-14 22:59:05 +09:00
Anders Bakken bc3dc6b765 Add set_nghttp2_debug_callback to take advantage of DEBUGF statements in
when building DEBUGBUILD.
2016-10-13 13:24:26 -07:00
Tatsuhiro Tsujikawa 392256e542 Add nghttp2_option_set_max_deflate_dynamic_table_size() API function
nghttp2_option_set_max_deflate_dynamic_table_size function sets the
maximum dynamic table size for header block deflater.  The default
value is 4KiB.
2016-09-11 22:13:59 +09:00
Tatsuhiro Tsujikawa 905e16cb99 Simplify session_after_frame_sent1 2016-09-11 17:18:08 +09:00
Tatsuhiro Tsujikawa 9d4e8eeb12 Simplify code
Move DATA frame handling code to switch-case of frame type.
2016-09-11 17:00:04 +09:00
Tatsuhiro Tsujikawa 6858cda366 Fix GOAWAY race with new incoming stream on server side
Revert part of 16c46114dc to fix race
condition that incoming stream after sending GOAWAY causes connection
error.  The strict stream handling introduced in the above commit does
not handle several cases well (e.g., GOAWAY race, and refusing streams
because of concurrency limit).
2016-09-09 22:08:34 +09:00
Tatsuhiro Tsujikawa fddb019baf Merge branch 'master' into http2-debug-state-api 2016-08-28 22:20:04 +09:00
Tatsuhiro Tsujikawa 581e0938a9 Allow NGHTTP2_ERR_PAUSE from nghttp2_data_source_read_callback 2016-08-28 21:57:10 +09:00
Tatsuhiro Tsujikawa baa0f60dc8 Add API to get current HPACK dynamic table size 2016-08-26 23:02:51 +09:00
Tatsuhiro Tsujikawa e693f75670 Add nghttp2_session_get_local_settings() API function 2016-08-21 19:33:01 +09:00
Tatsuhiro Tsujikawa 5cf21ec187 Add APIs to return the number of data that remote endpoint can send
2 APIs are added.  nghttp2_session_get_local_window_size() returns the
amount of data that the remote endpoint can send without receiving
connection level WINDOW_UPDATE.
nghttp2_session_get_stream_local_window_size() returns the amount of
data that the remote endpoint can send without receiving stream level
WINDOW_UPDATE.
2016-08-21 19:01:51 +09:00
Tatsuhiro Tsujikawa 8579b8a968 Merge pull request #646 from nghttp2/invalid-header-cb
Add nghttp2_on_invalid_header_callback
2016-08-15 11:13:20 +09:00
Tatsuhiro Tsujikawa 16c46114dc More strict stream state handling
Previously, in server side, we used closed streams to detect the error
that the misbehaving client sends a frame on the incoming stream it
explicitly closed.  With this commit, we make a further step, and
detect one more error case.  Since we retain closed streams as long as
the sum of its size and the number of opened streams are equal or less
than max concurrent streams, we can safely say that if we get a frame
which is sent on the stream that is not found in either closed or
opened stream, it is already closed or has not existed.  Then we can
send GOAWAY.

The previous code shrinks closed streams when we closed another
stream, but now it is removed.  It is enough to adjust closed streams
when new incoming stream is created.

While creating this commit, we noticed that
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS is defined as INT32_MAX.  But
since SETTINGS can contain value up to UINT32_MAX, it is not enough.
However, since the stream ID space is limited to INT32_MAX, it is high
enough.  We could keep this value, but this time we deprecate
NGHTTP2_INITIAL_MAX_CONCURRENT_STREAMS macro.  While it is in public
header, the effect of deprecating it is negligible because of the
reason we wrote above, and usually application sets much smaller value
(say, 100) as SETTINGS_MAX_CONCURRENT_STREAMS.
2016-08-07 19:31:00 +09:00
Tatsuhiro Tsujikawa 2f106dc96b Fix wrong tree operation to avoid cycle
https://tools.ietf.org/html/rfc7540#section-5.3.3 explains how to
transform dependency tree to avoid circular dependency.  Previously,
we wrongly always moved the dependent stream under the root stream.
The correct destination is the parent stream of the stream to
reprioritize.  This commit fixes this bug.
2016-08-04 22:20:07 +09:00
Tatsuhiro Tsujikawa 271f7fbbb6 Add nghttp2_on_invalid_header_callback
nghttp2_on_invalid_header_callback is similar to
nghttp2_on_header_callback, but the former is only called when the
invalid header field is received which is silently ignored when the
callback is not set.  With this callback, application inspects the
incoming invalid field, and it also can reset stream from this
callback by returning NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE, or using
nghttp2_submit_rst_stream() directly with the error code of choice.

We also added nghttp2_on_invalid_header_callback2, which uses
reference counted header fields.
2016-08-04 00:03:58 +09:00
Tatsuhiro Tsujikawa 318235db33 Log frame's stream ID for header debug logging
Previously, for PUSH_PROMISE frame, we logged its promised stream ID.
But it is saner to use just frame's ID in this context.
2016-08-03 00:17:38 +09:00
Tatsuhiro Tsujikawa 8ab079ccc2 Call error callback when invalid header field is received and ignored
We have a code to call error callback when invalid header is received
and it is treated as stream error.  But we didn't if the incoming
header is invalid, but just ignored.  This generosity is required to
handle public Internet connections especially when nghttp2 is used as
forward proxy.
2016-08-03 00:13:37 +09:00
Tatsuhiro Tsujikawa 110ca3131a Cancel frame transmission from before_frame_send_callback
We define the behaviour when NGHTTP2_ERR_CANCEL is returned from
before_frame_send_callback.  That is to cancel the frame passed to the
callback.
2016-07-02 19:21:08 +09:00
Tatsuhiro Tsujikawa 4aa79763be Clarify code path when appending inflight_settings 2016-06-21 22:32:08 +09:00
Tatsuhiro Tsujikawa 057db65657 Rewrite session_append_inflight_settings 2016-06-21 22:30:21 +09:00
Tatsuhiro Tsujikawa c7b0e04498 Add nghttp2_option_set_max_send_header_block_length API function
This function sets the maximum length of header block (a set of header
fields per HEADERS frame) to send.  The length of given set of header
fields is calculated using nghttp2_hd_deflate_bound().  Previously,
this is hard-coded, and is 64KiB.
2016-06-15 00:05:15 +09:00
Tatsuhiro Tsujikawa 2a96d433ec Add nghttp2_hd_inflate_hd2() and deprecate nghttp2_hd_inflate_hd()
The difference between them are former has const qualifier to the |in|
parameter, which is desirable since it is effectively read-only.
2016-05-14 18:25:20 +09:00
Tatsuhiro Tsujikawa dba0f35ee1 Avoid 0-length DATA if NGHTTP2_DATA_FLAG_NO_END_STREAM is set 2016-04-27 22:57:19 +09:00
Tatsuhiro Tsujikawa 3d948fd3d7 Zero fill in nghttp2_session_mem_send 2016-04-23 00:32:23 +09:00
Mike Conlen e04e24c1c2 in nghttp2_session_send() data is declared uninitialized and used
after a call to nghttp2_session_mem_send_internal() which should
set it, however in nghttp2_session_mem_send_internal() it is
possible to return before setting the pointer.

This change initializes the variable to NULL where delcared and
sets the variable in nghttp2_session_mem_send_internal() to
NULL before possibly returning rather than after.

both options are not necessary but are both ideal practice
2016-04-21 22:53:19 +00:00
Tatsuhiro Tsujikawa 4041d1eb26 Don't send ALTSVC if stream is closing 2016-04-15 00:59:05 +09:00
Tatsuhiro Tsujikawa 40f3779eb1 Pass unknown SETTINGS values to nghttp2_on_frame_recv_callback 2016-04-10 16:36:04 +09:00
Tatsuhiro Tsujikawa d4144a7475 altsvc: Add tests, ignore altsvc if stream does not exist 2016-04-09 19:14:15 +09:00
Tatsuhiro Tsujikawa 6638ca9333 altsvc: Reduce bitfield size 2016-04-09 18:23:15 +09:00
Tatsuhiro Tsujikawa b924ef5fff altsvc: Discard altsvc when it is received by server in earlier point 2016-04-08 23:25:56 +09:00
Tatsuhiro Tsujikawa df56f55f84 Assign nghttp2_frame.ext.payload early 2016-04-08 23:25:56 +09:00
Tatsuhiro Tsujikawa 795ee8c20f altsvc: Receive ALTSVC frame 2016-04-08 23:25:56 +09:00
Tatsuhiro Tsujikawa ecabef2dc7 altsvc: Add ALTSVC frame support 2016-04-08 23:25:56 +09:00
Tatsuhiro Tsujikawa 5974abad75 Run error callback when peer does not send initial SETTINGS frame 2016-04-02 18:20:49 +09:00
Tatsuhiro Tsujikawa 8667bbb823 Don't send WINDOW_UPDATE if session is being closed 2016-03-29 23:30:55 +09:00
Tatsuhiro Tsujikawa 37b09f6785 Use %u for uint8_t for formatting 2016-03-13 18:25:30 +09:00
Tatsuhiro Tsujikawa 2a606bae4c Add nghttp2_error_callback to tell application human readable error message 2016-03-13 18:22:52 +09:00
Tatsuhiro Tsujikawa 12dad32890 Add nghttp2_on_header_callback2 2016-03-12 21:13:09 +09:00
Tatsuhiro Tsujikawa ff0d137fb3 Reference counted HPACK name/value pair 2016-03-12 21:12:27 +09:00
Tatsuhiro Tsujikawa e453759637 Add nghttp2_option_set_no_auto_ping_ack() option
This option prevents the nghttp2 library from sending PING frame with
ACK flag set in the reply to incoming PING frame.  To allow the
application to send PING with ACK flag set, nghttp2_submit_ping() now
recognizes NGHTTP2_FLAG_PING in its flags parameter.
2016-02-29 23:39:50 +09:00
Tatsuhiro Tsujikawa 40c1b29f36 Handle extension frame in session_inbound_frame_reset 2016-02-25 21:18:59 +09:00
Tatsuhiro Tsujikawa 56bdfd1df2 Revert "Handle extension frame in session_inbound_frame_reset"
This reverts commit dbffb8995b.
2016-02-25 00:58:24 +09:00
Tatsuhiro Tsujikawa dbffb8995b Handle extension frame in session_inbound_frame_reset 2016-02-25 00:45:24 +09:00
Tatsuhiro Tsujikawa 827abb57e9 Simplified bitfield calculation of extension frame 2016-02-24 23:59:01 +09:00
Tatsuhiro Tsujikawa 34bf153653 Merge branch 'master' into simple-extensions 2016-02-24 23:21:03 +09:00
Tatsuhiro Tsujikawa 3e72711e23 Cap 100 limit for remembering idle streams 2016-02-23 01:09:45 +09:00
Tatsuhiro Tsujikawa 61dda40b44 Don't pass NULL to memcpy 2016-02-12 22:31:47 +09:00
Tatsuhiro Tsujikawa 304ff6a6f9 Don't send extension frame in closing state 2016-02-07 21:12:36 +09:00
Tatsuhiro Tsujikawa fc39f2d9d2 Merge branch 'master' into simple-extensions 2016-02-07 21:09:08 +09:00
Tatsuhiro Tsujikawa 4c05558273 Evaluate nghttp2_session_want_read and nghttp2_session_want_write when determining session is about to close 2016-02-03 00:25:11 +09:00