Commit Graph

625 Commits

Author SHA1 Message Date
Eliza Weisman
23090c9fed recv_reset resets closed streams with queued EOS frames (#247) 2018-03-27 21:20:16 -07:00
Carl Lerche
e61788a57f Accept HPACK literals greater than max size (#244)
The spec specifically allows accepting HPACK literals with indexing when
the HPACK literal is greater than the max table size. In this case, the
literal is not inserted in the table.

Fixes #243
2018-03-22 12:58:23 -07:00
Darren Tsung
4595b54cfa Add initial_max_send_streams() as builder option (#242) 2018-03-16 11:58:06 -07:00
Carl Lerche
0cb3e648e9 Bump version to v0.1.2 (#239) 2018-03-13 18:11:11 -07:00
Carl Lerche
5d4c89b1a9 Fix client doc test (#241)
The test is not supposed to actually run, but the `select` is not fast
enough on Travis.
2018-03-13 14:53:35 -07:00
Darren Tsung
f8baeb7211 Streams receiving peer reset clear pending send (#238)
Because streams that were being peer reset were not clearing pending
send frames / buffered_send_data, they were not being counted towards
the concurrency limit.
2018-03-13 12:47:57 -07:00
messense
267789da92 Update indexmap to 1.0 (#237) 2018-03-12 10:38:07 -07:00
Carl Lerche
70cf009305 Bump version to v0.1.1 (#236) 2018-03-08 10:06:40 -08:00
Carl Lerche
02841ebd77 Normalize HTTP request path. (#228)
The HTTP/2.0 specification requires that the path pseudo header is never
empty for requests unless the request uses the OPTIONS method.

This is currently not correctly enforced.

This patch provides a test and a fix.
2018-03-07 20:48:54 -08:00
Darren Tsung
bbed41974b Prevent pushing a stream into both pending_send + pending_open (#235)
Prevent pushing a stream into both pending_send + pending_open,
Clear out variables from buffered streams that get a reset, and
ignore them when traversing the pending_send queue if
they are is_reset(). Add asserts that a stream cannot be in
pending_open & pending_send at the same time.
2018-03-07 16:11:33 -08:00
Darren Tsung
200c04f1d3 Fix tests by switching to env_logger::try_init (#233) 2018-03-07 14:08:22 -08:00
Carl Lerche
dd0bb5b03e Add a comment explaining what pending_open is for (#232)
It isn't immediately obvious why the connection supports buffering
requests. The reason is that it models the futures' mpsc channel
behavior.

This patch adds a comment explaining this.
2018-03-07 13:48:20 -08:00
Sean McArthur
e3c6e0c590 Notify send_tasks when there is a connection error (#231) 2018-03-07 12:19:54 -08:00
Darren Tsung
ad90f9b97b Remove assert around self.pending_capacity.is_empty() (#225)
This assert does not hold as many streams can be pushed into
pending_capacity during a call to send_data(). See issue #224
for more discussion and sign-off.

Closes #224
2018-02-27 10:35:00 -08:00
Brian Smith
06672cbde9 Upgrade ordermap dependency to indexmap. (#227)
Avoid the need for indexmap-based applications to build ordermap,
which is the old name for indexmap.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-26 20:27:13 -08:00
Brian Smith
b6724f7d7a Upgrade to env_logger 0.5 & log 0.4; reduce related dependencies (#226)
Upgrade to env_logger 0.5 and log 0.4 so that projects that use those
versions don't have to build both those versions and the older ones
that h2 is currently using.

Don't enable the regex support in env_logger. Applications that want
the regex support can enable it themselves; this will happen
automatically when they add their env_logger dependency.

Disable the env_logger dependency in quickcheck.

The result of this is that there are fewer dependencies. For example,
regex and its dependencies are no longer required at all, as can be
seen by observing the changes to the Cargo.lock. That said,
env_logger 0.5 does add more dependencies itself; however it seems
applications are going to use env_logger 0.5 anyway so this is still
a net gain.

Submitted on behalf of Buoyant, Inc.

Signed-off-by: Brian Smith <brian@briansmith.org>
2018-02-23 20:25:42 -08:00
Darren Tsung
0c59957d88 When Streams are dropped, close Connection (#221) (#222)
When all Streams are dropped / finished, the Connection was held
open until the peer hangs up. Instead, the Connection should hang up
once it knows that nothing more will be sent.

To fix this, we notify the Connection when a stream is no longer
referenced. On the Connection poll(), we check that there are no
active, held, reset streams or any references to the Streams
and transition to sending a GOAWAY if that is case.

The specific behavior depends on if running as a client or server.
2018-02-15 13:14:18 -08:00
walfie
73b4c03b55 Fix typos (#223) 2018-02-13 21:00:09 -08:00
Steven Fackler
ef99f99ae1 Fix documentation for end_of_stream (#219)
The END_STREAM flag is set when the stream is ending, so it needs to be
false if we're sending data.
2018-01-25 11:58:41 -08:00
Sean McArthur
ef6fef8714 update readme to point usage example at crates.io (#218) 2018-01-12 11:54:22 -08:00
Steven Fackler
9f4d463dba Update dependency spec (#217) 2018-01-12 11:48:10 -08:00
Carl Lerche
758112acbe Update README 2018-01-12 09:18:39 -08:00
Carl Lerche
69bd8828ef Remove mock-io git dependency 2018-01-11 22:46:52 -08:00
Carl Lerche
f27056467c Track rustls / ring 2018-01-11 22:35:47 -08:00
Carl Lerche
983477ea50 Depend on string 0.1 2018-01-11 22:21:19 -08:00
Carl Lerche
54f300907f Update the Cargo.toml 2018-01-11 21:21:53 -08:00
Carl Lerche
1c8abf50df Update the README 2018-01-11 21:15:15 -08:00
Carl Lerche
91e200a3b1 Cleanup repo 2018-01-11 21:00:59 -08:00
Carl Lerche
78455a4496 Add docs for shared types (#216)
Add documentation for types shared between the client and server.
2018-01-11 15:00:16 -08:00
Carl Lerche
5604372a8b Client documentation (#212)
Add documentation for client APIs.
2018-01-11 13:55:51 -08:00
Carl Lerche
1db3f34de8 Implement SendRequest::ready. (#215)
This provides a functional future API for waiting for SendRequest
readiness.
2018-01-11 10:21:23 -08:00
Sean McArthur
aa23a9735d SETTINGS_MAX_HEADER_LIST_SIZE (#206)
This, uh, grew into something far bigger than expected, but it turns out, all of it was needed to eventually support this correctly.

- Adds configuration to client and server to set [SETTINGS_MAX_HEADER_LIST_SIZE](http://httpwg.org/specs/rfc7540.html#SETTINGS_MAX_HEADER_LIST_SIZE)
- If not set, a "sane default" of 16 MB is used (taken from golang's http2)
- Decoding header blocks now happens as they are received, instead of buffering up possibly forever until the last continuation frame is parsed.
- As each field is decoded, it's undecoded size is added to the total. Whenever a header block goes over the maximum size, the `frame` will be marked as such.
- Whenever a header block is deemed over max limit, decoding will still continue, but new fields will not be appended to `HeaderMap`. This is also can save wasted hashing.
- To protect against enormous string literals, such that they span multiple continuation frames, a check is made that the combined encoded bytes is less than the max allowed size. While technically not exactly what the spec suggests (counting decoded size instead), this should hopefully only happen when someone is indeed malicious. If found, a `GOAWAY` of `COMPRESSION_ERROR` is sent, and the connection shut down.
- After an oversize header block frame is finished decoding, the streams state machine will notice it is oversize, and handle that.
  - If the local peer is a server, a 431 response is sent, as suggested by the spec.
  - A `REFUSED_STREAM` reset is sent, since we cannot actually give the stream to the user.
- In order to be able to send both the 431 headers frame, and a reset frame afterwards, the scheduled `Canceled` machinery was made more general to a `Scheduled(Reason)` state instead.

Closes #18 
Closes #191
2018-01-05 09:23:48 -08:00
Sean McArthur
6f7b826b0a fix name change in server tests (#213) 2018-01-04 11:45:08 -08:00
Sean McArthur
3cbc158210 send reset CANCEL when SendStream is dropped with no end-of-stream sent (#210) 2018-01-04 11:06:06 -08:00
Carl Lerche
d0b5b6246a Misc renames (#202)
This patch renames a number of types and functions making
the API more consistent.

* `Server` -> `Connection`
* `Client` -> `SendRequest`
* `Respond` -> `SendResponse`.

It also moves the handshake fns off of `Connection` and make
them free fns in the module. And `Connection::builder` is removed
in favor of `Builder::new`.
2018-01-02 17:02:17 -08:00
Sean McArthur
26e7a2d416 remove erroneous assert when stream has buffered send data (#209) 2018-01-02 12:49:41 -08:00
Kenjiro Nakayama
ecf2e425b4 Add protocol version to response for client (#205) 2018-01-02 12:45:11 -08:00
Kenjiro Nakayama
0c67f7a390 Remove invalid brackets (#203) 2018-01-02 12:25:33 -08:00
Carl Lerche
a0e0d74edd Rust nightly is broken (#207) 2018-01-02 11:01:55 -08:00
Carl Lerche
de4c30a706 Switch unimplemented to assert (#201)
The only caller already guards against the case.

Relates to #192
2017-12-26 12:25:01 -08:00
Carl Lerche
fc75311fae Support writing continuation frames. (#198)
Large header sets might require being split up across multiple frames.
This patch adds support for doing so.
2017-12-20 17:24:29 -08:00
Sean McArthur
a89401dd91 reset pending push promises if user drops all refs (#199) 2017-12-20 16:50:20 -08:00
Sean McArthur
10d8ed7429 Add test that a window update can be received in reserved state (#195) 2017-12-19 20:07:39 -08:00
Carl Lerche
4cc573fa89 Don't panic on poll_trailers called out of order. (#189)
This patch removes a panic in `poll_trailers` that is triggered if
`poll_trailers` is called before `poll_data` returns `None`.

This is done by always trying to notify the receive task when
`poll_data` returns None and there already is pending trailers.
2017-12-19 20:05:12 -08:00
Sean McArthur
1552d62e7c ignore trailers for some time on locally reset streams (#194) 2017-12-19 15:06:05 -08:00
Carl Lerche
4f963588a8 Add more library API documentation (#190)
This includes a section on inbound data control flow.
2017-12-19 12:00:03 -08:00
Carl Lerche
6e1d0930bf Tweak CONTRIBUTING 2017-12-18 22:22:40 -08:00
Carl Lerche
d4fc88f605 Remove rustfmt reference from CONTRIBUTING 2017-12-18 22:17:42 -08:00
Sean McArthur
eafd6bfd98 release connection capacity when recv_data has stream error (#186) 2017-12-18 15:08:21 -08:00
Carl Lerche
1a0b1eec2b Start writing API docs (#187)
This focuses mostly on the server module.
2017-12-18 14:27:30 -08:00