Commit Graph

1458 Commits

Author SHA1 Message Date
Tatsuhiro Tsujikawa 8034221525 Implement ORIGIN frame 2018-05-12 12:35:08 +09:00
Tatsuhiro Tsujikawa a5c408c5e3 Ignore all input after calling session_terminate_session 2018-04-22 14:42:28 +09:00
Tatsuhiro Tsujikawa 06379b2861 Fix treatment of padding 2018-04-22 14:42:28 +09:00
Tatsuhiro Tsujikawa b1bd6035e8 Fix frame handling 2018-04-07 00:27:55 +09:00
Viktor Szakats f342260bfe cmake: add ENABLE_STATIC_LIB option to build static lib
When using the ENABLE_LIB_ONLY option, only the shared
library was built. This new option allows to build the
static library as well.
2018-03-12 22:41:37 +00:00
Tatsuhiro Tsujikawa 842509dab6 Don't allow 101 HTTP status code because HTTP/2 removes HTTP Upgrade 2018-03-11 15:37:30 +09:00
Tatsuhiro Tsujikawa 17793e99dc Add nghttp2_session_set_user_data() public API function 2018-02-22 21:02:16 +09:00
Tatsuhiro Tsujikawa acd6b40e4c Allow PING frame to be sent after GOAWAY 2018-01-08 17:03:48 +09:00
Tatsuhiro Tsujikawa 422ad1be32 Use NGHTTP2_REFUSED_STREAM for streams which are closed by GOAWAY
The error code NGHTTP2_REFUSED_STREAM is passed to
nghttp2_on_stream_close callback when a stream is closed because its
stream ID is strictly larger than incoming or outgoing GOAWAY.
2017-11-30 23:10:57 +09:00
Tatsuhiro Tsujikawa 53aeb2c3d7 Fix doc 2017-11-24 22:26:29 +09:00
Tatsuhiro Tsujikawa ff200bfcf3 clang-format-5.0 2017-11-23 14:19:12 +09:00
Tatsuhiro Tsujikawa 43a2a70ae7 Add nghttp2_error_callback2
nghttp2_error_callback2 is an extended version of the existing
nghttp2_error_callback by adding error code parameter.  This
deprecates nghttp2_error_callback.
2017-11-19 16:51:52 +09:00
Tatsuhiro Tsujikawa aaeeec8f1c Fix typos 2017-10-28 22:25:42 +09:00
Tatsuhiro Tsujikawa 6635ca5e26 Merge pull request #988 from dvetutnev/refactoring_include_directories
Refactoring include directories
2017-08-23 18:59:28 +09:00
Tatsuhiro Tsujikawa 0d91e9c255 Update doc 2017-08-18 22:06:43 +09:00
Dmitriy Vetutnev af926fbe1f Refactoring include directories for build as CMake subdirectory (add_subdirectory(nghttp2)) 2017-08-16 21:28:12 +03:00
Anna Henningsen eb306f463e
lib: add nghttp2_rcbuf_is_static()
Add a `nghttp2_rcbuf_is_static()` method to tell whether a rcbuf
is statically allocated.

This can be useful for language bindings that wish to avoid
creating duplicate strings for these buffers; concretely, I am
planning to use this in the Node HTTP/2 module that is being
introduced.
2017-08-12 17:48:14 +02:00
Tatsuhiro Tsujikawa 0f69e9c825 Fix typo 2017-07-28 00:51:34 +09:00
Sebastiaan Deckers c601e603c2 fix: typo
Came up in downstream code review by @lucaslago https://github.com/nodejs/node/pull/14239#discussion_r127539852
2017-07-15 07:46:26 +08:00
Benjamin Peterson b7c95be47c fix up grammar in submit_trailer docs 2017-06-18 23:55:53 -07:00
Tatsuhiro Tsujikawa 1b442cb16f Compile with --disable-assert 2017-05-18 23:10:44 +09:00
Angus Gratton e17ff8fd32 nghttp2_session: Allow for compiling library with -DNDEBUG set 2017-05-17 14:43:06 +10:00
Tatsuhiro Tsujikawa d3fcbe9a02 Merge branch 'invalid-header-field-error' 2017-05-12 21:37:20 +09:00
Tatsuhiro Tsujikawa a584cf5a4f Use clang-format-4.0 2017-04-30 15:45:53 +09:00
Tatsuhiro Tsujikawa f2c539dc70 Clarify the effect of nghttp2_option_set_no_http_messaging 2017-04-29 21:00:20 +09:00
Tatsuhiro Tsujikawa 78d7160a99 Treat incoming invalid regular header field as stream error
Previously, the incoming invalid regular header field was ignored by
default.  With this commit, they are now treated as stream error, and
the stream is reset by default.  The error code used is now
PROTOCOL_ERROR, instead of INTERNAL_ERROR.
2017-04-28 23:46:06 +09:00
Tatsuhiro Tsujikawa 21af775ce0 Call nghttp2_on_invalid_frame_callback if altsvc validation fails 2017-04-27 18:53:43 +09:00
Tatsuhiro Tsujikawa 2358a2137a Refactor predicate functions 2017-04-26 22:31:43 +09:00
Tatsuhiro Tsujikawa 66baa7dc25 Estimate header block size after predicate function succeeds 2017-04-26 22:15:53 +09:00
lstefani 25cda200be Update nghttp2_session.c
Add missing free call on error in inflight_settings_new().
2017-04-13 10:00:15 -04:00
Tatsuhiro Tsujikawa 85a12429ee Eliminate _U_ macro
Instead use (void)VAR for better compiler compatibility.
2017-03-11 18:45:49 +09:00
Tatsuhiro Tsujikawa 54f4b85beb Fix nghttp2_session_want_write
This commit fixes the bug in nghttp2_session_want_write.  Previously,
it may return 0 if there is pending frames after GOAWAY frame is
submitted.

To avoid the situation that nghttp2_session_want_write keeps returning
nonzero after GOAWAY and the number of active streams is 0 (e.g., keep
receiving SETTINGS or PING), nghttp2_session_mem_recv now just
swallows the input data without parsing in this case.
2017-03-07 22:55:39 +09:00
Tatsuhiro Tsujikawa 368775c2ed Merge pull request #814 from alagoutte/pvs
nghttp2_session: fix The 'then' statement is equivalent to the subseq…
2017-02-15 21:15:43 +09:00
Alexis La Goutte ceb4dcf3b2 nghttp2_session: fix The 'then' statement is equivalent to the subsequent code fragment found by PVS Studio (V523) 2017-02-14 17:40:51 +01:00
Tatsuhiro Tsujikawa f3a5a0a0ec Add nghttp2_option_no_closed_streams
nghttp2_option_no_closed_streams controls whether closed streams are
retained or not.  If nonzero is passed to that function's parameter
val, a session does not retain closed streams.  It may hurt the shape
of priority tree, but can save memory.
2017-02-13 22:33:29 +09:00
Tatsuhiro Tsujikawa 5f31c09410 Mention about nghttp2_data_source_read_length_callback 2017-02-08 00:40:47 +09:00
Tatsuhiro Tsujikawa 052f3a3871 Update doc 2017-01-26 23:40:12 +09:00
Tatsuhiro Tsujikawa becae65257 Fix leak 2017-01-24 22:59:01 +09:00
Alexis La Goutte ae87a44b94 nghttp2_hd: fix It is odd that the body of 'hd_get_num_table_entries' function is fully equivalent to the body of 'get_max_index' function found by PVS Studio (V524) 2017-01-03 22:03:53 +01:00
Alexis La Goutte 87d1692e27 nghttp2_submit: fix Parameter 'flags' is always rewritten in function body before being used found by PVS Studio (V763) 2017-01-03 22:03:53 +01:00
Tatsuhiro Tsujikawa 5645cad577 Accept and ignore content-length: 0 in 204 response for now 2016-12-03 14:57:16 +09:00
Matt Rudary 5a81f2441f Prevent undefined behavior in decode_length 2016-11-11 11:12:43 -05:00
Tatsuhiro Tsujikawa 6ad9ddcdea Disallow content-length in 1xx, 204, or 200 to a CONNECT request 2016-11-03 17:26:32 +09:00
Tatsuhiro Tsujikawa ca6f6511f2 Avoid memcpy against NULL src 2016-11-01 23:54:21 +09:00
Remo E 9cd695a1db MSVC version resource support 2016-10-28 22:24:22 +09:00
Tatsuhiro Tsujikawa 0cf6848646 clang-format-3.9 2016-10-15 18:36:04 +09:00
Tatsuhiro Tsujikawa bc0f501dd3 Replace final with fin to make clang-format-3.9 happy 2016-10-15 18:25:13 +09:00
Tatsuhiro Tsujikawa a591001e7b Update doc 2016-10-15 18:18:52 +09:00
Tatsuhiro Tsujikawa 1d5cde1c6b Add missing nghttp2_debug.h 2016-10-14 23:13:42 +09:00
Tatsuhiro Tsujikawa 19340da8d4 Re-format debug text output 2016-10-14 22:59:05 +09:00
Tatsuhiro Tsujikawa 5e99531b4d clang-format 2016-10-14 22:59:05 +09:00
Tatsuhiro Tsujikawa bef3d47c16 Rename functions and nghttp2_debug.h to move debug macro there 2016-10-14 22:59:05 +09:00
Tatsuhiro Tsujikawa b8f7b474b4 Fix autotools build 2016-10-14 22:04:02 +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 743fc4a3c3 Use the similar naming scheme for table size as 392256e542 2016-09-11 22:25:01 +09: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 79b07f0ce2 Update doc 2016-08-28 00:47:38 +09:00
Tatsuhiro Tsujikawa baa0f60dc8 Add API to get current HPACK dynamic table size 2016-08-26 23:02:51 +09:00
Tatsuhiro Tsujikawa 69aa70086a Merge branch 'master' into http2-debug-state-api 2016-08-26 22:54:59 +09:00
Wenfeng Liu 00c80a15c0 lib: Make emit_header() return void since it always succeed. 2016-08-23 13:40:14 +00:00
Tatsuhiro Tsujikawa e693f75670 Add nghttp2_session_get_local_settings() API function 2016-08-21 19:33:01 +09:00
Tatsuhiro Tsujikawa 759f6c0b39 Update doc 2016-08-21 19:17:51 +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 62e1d1c952 Fix typo 2016-08-21 13:29:29 +09:00
Tatsuhiro Tsujikawa 09c647fd1b Update doc 2016-08-18 21:26:58 +09:00
Tatsuhiro Tsujikawa d0fea96e69 Allow nonuniform buffer size in nghttp2_hd_deflate_hd_vec() 2016-08-18 21:23:17 +09:00
Tatsuhiro Tsujikawa 40d217beb1 Remove bufs_avail 2016-08-17 22:56:40 +09:00
Tatsuhiro Tsujikawa 9b864380a5 Use nghttp2_vec in nghttp2_hd_deflate_hd_vec
This change is for the future enhancement where we loose the
requirement about the chunk size for each buffer.
2016-08-17 21:09:29 +09:00
Tatsuhiro Tsujikawa 0e1d0400d8 Use whole chunk when performing huffman encoding 2016-08-17 21:05:04 +09:00
Wenfeng Liu 488c3588d9 lib: Malloc nghttp2_buf_chain array once in nghttp2_bufs_wrap_init2()
to simplify logic
2016-08-17 20:48:03 +09:00
Tatsuhiro Tsujikawa 8acef2711b Use pointer-to-pointer idiom to construct linked list 2016-08-16 13:02:24 +09:00
Tatsuhiro Tsujikawa c4d36aeff7 Make parameters const pointer 2016-08-16 10:55:51 +09:00
Tatsuhiro Tsujikawa f50596e355 Merge branch 'master' of https://github.com/weliu/nghttp2 into weliu-master 2016-08-16 09:59:50 +09:00
Wenfeng Liu abf81b5bb7 lib: Add nghttp2_hd_deflate_hd_vec() deflate API to support multiple bufs input 2016-08-15 10:28:45 +00: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 4c381611a1 More doc about HPACK decoding API 2016-08-11 11:47:53 +09:00
Tatsuhiro Tsujikawa 0c7d48dede Make result type of hd_inflate_commit_indexed void 2016-08-11 11:33:09 +09:00
Wenfeng Liu 65cc2f0515 lib: since hd_inflate_commit_indexed() always return 0, remove the
return value check in nghttp2_hd_inflate_hd_nv().
2016-08-11 02:00:43 +00:00
Tatsuhiro Tsujikawa 3f31424ee2 Merge branch 'master' of https://github.com/weliu/nghttp2 into weliu-master 2016-08-09 22:01:10 +09:00
Wenfeng Liu e0119452a3 Use memeq() instead of lstreq() in lookup_token(). 2016-08-09 04:15:38 +00:00
Tatsuhiro Tsujikawa 60cae325bc Search dynamic table first for optimization 2016-08-08 00:27:16 +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 e7e3d77c53 Merge branch 'master' of https://github.com/weliu/nghttp2 into weliu-master 2016-08-06 22:42:22 +09:00
Wenfeng Liu af9aeee752 1. Modify genlibtokenlookup.py to remove redundant header comparisons.
2. Remove inline qualifier of lookup_token() in genlibtokenlookup.py.
2016-08-05 09:56:15 +00:00
Tatsuhiro Tsujikawa b7a72b1e5a Merge branch 'master' of https://github.com/weliu/nghttp2 into weliu-master 2016-08-04 22:25:25 +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
Wenfeng Liu f619286ca3 Make get_max_index() return the max index in frame, so we don't need
to do extra calculation
2016-08-04 01:26:13 +00: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 8b50cc0ece Update doc 2016-07-21 21:18:21 +09:00
Tatsuhiro Tsujikawa 0cb0bdabec Update doc 2016-07-13 22:01:31 +09:00
Tatsuhiro Tsujikawa ed8d5f04bb Update doc 2016-07-10 19:07:03 +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 fdc27c9f0e Specify 1 for 2nd parameter of fwrite as a convention 2016-06-22 23:29:09 +09:00