Commit Graph

323 Commits

Author SHA1 Message Date
Sean McArthur
018f00b8db update flow control tests to use frame builders 2017-09-07 17:06:09 -07:00
Sean McArthur
aef11623ac add recv_frame and send_frame extensions for Handle Futures 2017-09-07 17:05:43 -07:00
Sean McArthur
cc70ac1ef2 fix style to match crate 2017-09-07 17:05:07 -07:00
Carl Lerche
ae6bad6cef Fix some flow control bugs
When a stream is closed, connection level capacity should be released
back to the connection and then assigned to other streams waiting for
capacity.
2017-09-07 16:45:20 -07:00
Carl Lerche
9b42dafd24 Extract drive combinator to test support 2017-09-07 15:36:54 -07:00
Carl Lerche
38bbf30b2f Fix bug in prioritization (#63)
The stream buffered data counter was never decremented.
2017-09-07 14:12:21 -07:00
Sean McArthur
342d283cc5 add ergonomics to testing with frames 2017-09-07 13:09:57 -07:00
Sean McArthur
09744f38ef add a ReleaseCapacityTooBig variant to UserError 2017-09-07 08:20:03 -07:00
Sean McArthur
452e49dc3e aggregate WINDOW_UPDATE frames until change is over 50% available 2017-09-07 08:20:03 -07:00
Eliza Weisman
b040ca1478 Add codecov.io coverage reporting (#58) 2017-09-06 16:08:51 -07:00
Carl Lerche
cd76aca6d4 Add test infrastructure to work directly with frames (#56)
This adds a `Codec` based testing API. This is a bit less annoying than writing
at the raw H2 wire protocol level...
2017-09-06 14:18:37 -07:00
Oliver Gould
711086c184 cache cargo dependencies (#54) 2017-09-05 20:17:48 -07:00
Oliver Gould
8b07a4298c Remove the AsyncRead + AsyncWrite type constraint from h2::client::Client (#53) 2017-09-05 20:17:32 -07:00
Carl Lerche
0cc611df35 Add Codec::set_max_send_frame_size 2017-09-05 14:01:32 -07:00
Carl Lerche
c2e6eb35d8 Track HTTP crate 2017-09-05 10:21:31 -07:00
Carl Lerche
b4fa5134f9 Data frame (#50)
* Rename DataFlag -> DataFlags
* Polish Data frame API
2017-09-05 10:00:05 -07:00
eyelash
bbcfffee46 Fix hyper link in README (#51) 2017-09-04 08:55:52 -07:00
Carl Lerche
88d1de2da0 Expose Codec via an unstable flag (#49)
Exposes `Codec` using an unstable flag. This is useful for testing.
2017-09-03 16:17:05 -07:00
Carl Lerche
c122e97127 Refactor errors (#46)
This patch does a bunch of refactoring, mostly around error types, but it also
paves the way to allow `Codec` to be used standalone.

* `Codec` (and `FramedRead` / `FramedWrite`) is broken out into a codec module.
* An h2-codec crate is created that re-exports the frame and codec modules.
* New error types are introduced in the internals:
  * `RecvError` represents errors caused by trying to receive a frame.
  * `SendError` represents errors caused by trying to send a frame.
  * `UserError` is an enum of potential errors caused by invalid usage
    by the user of the lib.
  * `ProtoError` is either a `Reason` or an `io::Error`. However it doesn't
    specify connection or stream level.
  * `h2::Error` is an opaque error type and is the only error type exposed
    by the public API (used to be `ConnectionError`).

There are misc code changes to enable this as well. The biggest is a new "sink"
API for `Codec`. It provides buffer which queues up a frame followed by flush
which writes everything that is queued. This departs from the `Sink` trait in
order to provide more accurate error values. For example, buffer can never fail
(but it will panic if `poll_ready` is not called first).
2017-09-02 11:12:50 -07:00
Carl Lerche
6fd9674759 Validate received content-length header (#43)
If a content-length header is provided, the value should match the sum
of all data frame lengths. If there is a mismatch, then the stream is
reset.
2017-08-31 12:40:02 -04:00
Carl Lerche
0b1fbc4b39 Exclude possibly sensitive data from logs
Header fields and data frames can potentially contain sensitive data.
This change omits these from Debug output which reduces the chance that
this ends up in logs.
2017-08-30 18:23:23 -04:00
Eliza Weisman
a466646e19 Unbox client handshake future (#42) 2017-08-30 18:17:09 -04:00
Carl Lerche
2452cc4423 Validate & convert messages before buffering
Malformed requests and responses should immediately result in a
RST_STREAM. To support this, received header frames are validated and
converted to Request / Response values immediately on receipt and before
buffering.
2017-08-30 18:16:21 -04:00
Carl Lerche
9bb34d907a Thread P generic through all 2017-08-30 18:16:21 -04:00
Carl Lerche
88a7d56a60 PRIORITY frames with id 0 are invalid 2017-08-30 18:16:21 -04:00
Carl Lerche
15f6dfd2c1 Handle invalid stream deps with RST_STREAM 2017-08-30 18:16:21 -04:00
Carl Lerche
14f35f1be6 Handle malformed HEADERS 2017-08-30 18:16:21 -04:00
Carl Lerche
9d45255c75 H2 headers must be lower case 2017-08-30 18:16:21 -04:00
Carl Lerche
91aa1db2ff Misc protocol fixes
* Verify contiuation frame stream ID
* Fix sending RST_STREAM in certain cases.
2017-08-30 18:16:21 -04:00
Carl Lerche
0c8a94aa11 Fix send flow control bug
The send stream state is transitioned before data is buffered. As such,
the stream state could be closed while there is still data to be sent.
2017-08-30 18:16:21 -04:00
Brian Smith
63ba0073a4 Update TLS-related dependencies. (#41)
Use a temporary private fork of tokio-rustls that uses Rustls 0.12
until tokio-rustls 0.4 is released.

This upgrades, among other things, *ring* to 0.12, which will ensure
that it still builds in the Rust 1.20 release coming this week even if
backward-compatibility-breaking changes to rustc aren't fixed before
the release.
2017-08-29 13:23:38 -04:00
Carl Lerche
11df3633a4 Fix build on nightly 2017-08-29 12:20:44 -04:00
Carl Lerche
11d5f95236 Wire in trailers (#34)
Add send and receive trailer support.
2017-08-25 10:20:47 -07:00
Carl Lerche
c0433e8831 Fix tests & bug introduced in previous commit 2017-08-24 16:48:01 -07:00
Carl Lerche
b0e6867877 Fix warnings 2017-08-24 15:52:01 -07:00
Carl Lerche
638791ac6c Remove some CI platforms 2017-08-24 13:09:39 -07:00
Carl Lerche
6a6c9665cd Immediately apply initial window size to streams
The initial window size should be applied to streams once they leave the
IDLE state.
2017-08-24 11:03:33 -07:00
Carl Lerche
66dbde92ef Do not reuse next ptr for multiple linked lists
Because, you might think that each linked list has exclusive access to
the next pointer, but then there is an edge case that proves otherwise.
Also, debugging this kind of thing is annoying.
2017-08-23 20:35:53 -07:00
Carl Lerche
7e8c7fd2b8 Use FlowControl::available to size data frames (#29) 2017-08-23 20:34:58 -07:00
Oliver Gould
f839443ece implement h2::server::Stream::send_reset(Reason) and Body::is_empty() (#22) 2017-08-23 12:48:00 -07:00
Carl Lerche
e8f757457b Update server example 2017-08-23 11:24:54 -07:00
Carl Lerche
807d2b7317 Wire in recv flow control (#26) 2017-08-23 11:22:24 -07:00
Carl Lerche
a623ab68b5 New send flow control (#25)
Restructure send flow control such that sending data is always accepted by `Stream`. Data frames will be buffered until there is available window to send them. Producers can monitor the available window capacity to decide if data should be produced.
2017-08-21 13:52:58 -07:00
Carl Lerche
41b25a4a56 Fix README example 2017-08-17 07:22:26 -07:00
Carl Lerche
cd2bc41adc Improve the README 2017-08-16 22:23:45 -07:00
Carl Lerche
8ea99dd3ff Use travis to run CI 2017-08-16 21:49:25 -07:00
Brian Smith
2992594552 Switch Akamai example from rust-openssl to Rustls. (#24)
With this change, h2 can build and run without any manual configuration steps for -msvc targets. Previously manual installation of OpenSSL libraries was required.
2017-08-16 21:43:35 -07:00
Brian Smith
72f1d372af Fix build by upgrading tokio-io dependency to tokio-io 0.1.3. (#23)
tokio-io 0.1.3 has been published so the "replace" for tokio-io 0.1.2 is no longer useful and it breaks the build with some (but apparently not all) versions of Cargo.

Update the dependency to tokio-io 0.1.3 since that is the version that's what's been verified to work.
2017-08-16 21:40:53 -07:00
Carl Lerche
de96b2f410 Add another test 2017-08-16 12:43:48 -07:00
Oliver Gould
e015d7bfba Implement Client::poll_ready (#21)
Client::poll_ready ensures that the connection is ale to to initiate a new request stream to the remote server.  When the server is at capacity, a task is stored to be notified when capacity is available.
2017-08-15 13:46:55 -07:00