Commit Graph

317 Commits

Author SHA1 Message Date
Sean McArthur
2be2523162 notify stream refs when the connection receives EOF (#176) 2017-11-28 13:42:22 -08:00
Sean McArthur
79003d0d45 reject connection-specific headers (#173)
- When receiving, return a PROTOCOL_ERROR.
- When sending, return a user error about malformed headers.

Closes #36
2017-11-14 11:16:29 -08:00
Eliza Weisman
05abb686cf Add test for #38 (#162)
As requested in https://github.com/carllerche/h2/issues/38#issuecomment-328254128, I've added a test to `stream_states.rs` to cover the case where we receive a HEADERS frame that gets rejected (due to being malformed), then the same stream ID is received with a valid HEADERS frame which gets accepted.

Closes #38
2017-10-27 15:22:12 -07:00
Eliza Weisman
8a1c4d3d52 Add test and assertion for idle state handling (#160) 2017-10-27 14:14:00 -07:00
Sean McArthur
b1d282799b Add must_use to futures, deny missing docs (#171) 2017-10-27 14:08:16 -07:00
Sean McArthur
24a796da72 remove unused tokio-timer dependency (#170) 2017-10-27 13:11:06 -07:00
Carl Lerche
d57a2fecd1 Add FAQ section to readme (#169) 2017-10-26 11:07:11 -07:00
Oliver Gould
2e28f553ba Expose h2::Error::reason (#166) 2017-10-21 13:00:35 -07:00
Eliza Weisman
6a0800d7a4 Clear up unreachable message (#161) 2017-10-21 13:00:15 -07:00
Carl Lerche
c23d11306e Add RecvStream::is_end_stream. (#165)
This function returns true if the `RecvStream` has reached an end of
stream state. This is intended to replace `is_empty` which has confusing
behavior.
2017-10-21 09:59:27 -07:00
Carl Lerche
17453dd307 Loosen some bounds. (#163) 2017-10-20 20:45:09 -07:00
Sean McArthur
75db186378 fix panic when a stream is canceled (#164) 2017-10-20 17:47:58 -07:00
Eliza Weisman
0ed1460016 Add h2spec executable to .gitignore (#159)
Turns out issue #158 was caused by me accidentally committing an h2spec mac executable, breaking CI when it attempts to download and run a linux h2spec executable. I figured h2spec ought to be in the gitignore so that something like this won't happen again, since the CI script for running h2spec tests whether a file named `h2spec` exists before deciding whether or not to download it.
2017-10-20 10:44:31 -07:00
Carl Lerche
c4fc2928fe API cleanup (#155)
* Change send_reset to take &mut self.

While calling this function is the last thing that should be done with
the instance, the intent of the h2 library is not to be used directly by
users, but to be used as an implementation detail by other libraries.

Requiring `self` on `send_reset` is pretty annoying when calling the
function from inside a `Future` implementation. Also, all the other fns
on the type take `&mut self`.

* Remove the P: Peer generic from internals

* Split out `Respond` from `server::Stream`

This new type is used to send HTTP responses to the client as well as
reserve streams for push promises.

* Remove unused `Send` helper.

This could be brought back later when the API becomes stable.

* Unite `client` and `server` types

* Remove `B` generic from internal proto structs

This is a first step in removing the `B` generic from public API types
that do not strictly require it.

Currently, all public API types must be generic over `B` even if they do
not actually interact with the send data frame type. The first step in
removing this is to remove `B` as a generic on all internal types.

* Remove `Buffer<B>` from inner stream state

This is the next step in removing the `B` generic from all public API
types. The send buffer is the only type that requires `B`. It has now
been extracted from the rest of the stream state.

The strategy used in this PR requires an additional `Arc` and `Mutex`,
but this is not a fundamental requirement. The additional overhead can
be avoided with a little bit of unsafe code. However, this optimization
should not be made until it is proven that it is required.

* Remove `B` generic from `Body` + `ReleaseCapacity`

This commit actually removes the generic from these two public API
types. Also note, that removing the generic requires that `B: 'static`.
This is because there is no more generic on `Body` and `ReleaseCapacity`
and the compiler must be able to ensure that `B` outlives all `Body` and
`ReleaseCapacity` handles.

In practice, in an async world, passing a non 'static `B` is never going
to happen.

* Remove generic from `ResponseFuture`

This change also makes generic free types `Send`. The original strategy
of using a trait object meant that those handles could not be `Send`.
The solution was to avoid using the send buffer when canceling a stream.
This is done by transitioning the stream state to `Canceled`, a new
`Cause` variant.

* Simplify Send::send_reset

Now that implicit cancelation goes through a separate path, the
send_reset function can be simplified.

* Export types common to client & server at root

* Rename Stream -> SendStream, Body -> RecvStream

* Implement send_reset on server::Respond
2017-10-19 20:02:08 -07:00
Eliza Weisman
1e126aa752 Unbox server handshake future (#52)
Server-side version of #42. I've rewritten `server::Handshake` as a hand-rolled `Future` rather than as a `Box<Future>`. In addition to removing a `Box`, this also means that the `'static` lifetime bounds on the type parameters `T` and `B` can be removed.

The type of the server handshake future is somewhat more complex than the client-side handshake future. Note also that I've had to re-export `proto::streams::Prioritized` as `pub(crate)` from `proto`, as it appears in the type of the handshake future.

I've ran the tests against this branch and everything passes. Since no new functionality was added, I haven't added any additional tests.

This also fixes #158 - I had accidentally committed a Darwin h2spec executable and that's what was breaking CI.
2017-10-19 12:21:13 -07:00
Carl Lerche
58c55564e2 Fix race in test (#157)
This fixes a race condition in a test that has been exposed by
CI.

This commit also disables code coverage checks as it has been
causing CI to hang. See #156.
2017-10-18 11:00:56 -07:00
Carl Lerche
faf59f7e24 Split response future from client::Stream (#153) 2017-10-16 20:17:07 -07:00
Carl Lerche
7c287af0d0 Fix some flow control bugs. (#152)
* Release stream capacity back to the connection to avoid capacity
leaks.
* Actually notify waiting tasks when capacity becomes available.
2017-10-13 14:15:20 -07:00
Sean McArthur
5c1bde7d62 add set_target_window_size methods to Server and Client (#149)
Closes #101
2017-10-13 11:19:56 -07:00
Eliza Weisman
2fcf8c3740 Add methods to {client, server}::Builder to set max concurrent streams (#150)
This PR adds `max_concurrent_streams()` methods to the client and server `Builder`s to set the `max_concurrent_streams` setting. I've added unit tests to ensure the correct SETTINGS frame is sent.

Closes #106
2017-10-10 17:36:45 -05:00
Sean McArthur
c6a233281a custom Debug for Reason (#151) 2017-10-10 14:30:34 -07:00
Eliza Weisman
cca5d8fb83 Workaround for #142 (#144) 2017-10-09 16:36:13 -07:00
Oliver Gould
80e3478c00 Use remote window size for send flow control (#145)
The initial window size of both the send and recv flow controllers are
configured from the same setting. The send flow controller should be
configured from the remote's initial window size.
2017-10-09 15:16:22 -07:00
Carl Lerche
4c7ecf158d Add ReleaseCapacity handle. (#148)
This enables releasing stream capacity without having the `Body` handle.
2017-10-09 14:00:28 -07:00
Carl Lerche
56db50526d Don't unwrap logger init in tests 2017-10-09 13:10:52 -07:00
Sean McArthur
08a642ab11 fix ICE when compiling prioritization tests (#147) 2017-10-09 13:05:15 -07:00
Carl Lerche
be5f1d702a Fix doc link in README 2017-10-09 11:21:05 -07:00
Holt Chesley
2aee78c7d7 Issue 128: Convert frame::Reason to struct (#142)
Alter frame::Reason to a struct with a single u32 member.
Introduce Constants to the impl for existing Reasons. Change all usage
in the library and its tests to adopt this change,
using the new constants.
2017-10-08 13:13:07 -07:00
Oliver Gould
1c179f7bf2 Depend on http:0.1 (#141) 2017-10-07 12:34:46 -07:00
Sean McArthur
bc679035f9 remove panic from Debug of StreamRef is mutex is poisoned 2017-10-06 14:20:32 -07:00
Sean McArthur
7b81be04aa reduce available window capacity when settings lowers window size 2017-10-06 14:20:32 -07:00
Sean McArthur
431442735d reset streams when receiving invalid psuedo headers 2017-10-06 13:48:30 -07:00
Sean McArthur
7d1732a70d change unimplemented to unreachable in handshake 2017-10-06 09:59:03 -07:00
Sean McArthur
9737d0c6a0 convert several unimplemented into proper asserts 2017-10-06 09:59:03 -07:00
Sean McArthur
38900df185 reset stream if invalid content-length received 2017-10-06 09:59:03 -07:00
Sean McArthur
447102beeb return PayloadTooBig if user calls send_data with buffer over max window size 2017-10-06 09:59:03 -07:00
Sean McArthur
7ad29932f6 change huffman unimplemented to return Err in decode4 2017-10-06 09:59:03 -07:00
Sean McArthur
720fb20bbf remove unused pieces from PingPong (#134)
Adds some extra tests as well, to be sure.
2017-10-05 19:16:14 -07:00
Eliza Weisman
2e3dcf602c StreamRef sends RST_STREAM on drop (#109)
This PR modifies the `Drop` implementation for `StreamRef` to reset the underlying stream if it is the last reference to that stream. Since both `Stream` and `Body` are internally just a `StreamRef`, this means they will both reset the stream on drop; thus, this closes #100.

The assertion that the store no longer contains the dropped stream ID at the end of the `Drop` method  had to be removed, as the stream has to be reset from inside of a `transition` block (which now manages releasing that ID for us), and the `transition` closure moves the value of `stream`, making the assertion no longer possible.

Modifications to some of the tests in `flow_control.rs` were also necessary, in order to prevent `StreamRef`s from being dropped too early.
2017-10-05 18:05:18 -05:00
Sean McArthur
ecd2764f4b when receiving a GOAWAY, allow earlier streams to still process (#133)
Once all active streams have finished, send a GOAWAY back and close the
connection.
2017-10-05 15:32:13 -07:00
Sean McArthur
c4ca8f7def Client::poll_ready and send_request may return Connection Errors (#132)
Closes #131
2017-10-04 15:22:10 -07:00
Sean McArthur
9e1a0c63cf add send_reset to client::Stream (#127)
Closes #99
2017-09-29 11:37:23 -07:00
Sean McArthur
f8efb053b9 split Client into (Client, Connection) (#107)
The Connection type is a `Future` that drives all of the IO of the
client connection.

The Client type is separate, and is used to send requests into the
connection.
2017-09-28 16:55:12 -07:00
Sean McArthur
510800ef28 remove rustfmt from CI while its unstable (#126) 2017-09-28 16:27:24 -07:00
Eliza Weisman
307ad46ead Set codecov pass threshold to 5% (#124) 2017-09-28 10:55:29 -07:00
Eliza Weisman
c1fbabf686 Make CI build flatter (and therefore faster) (#123)
Now with a fancier script for running h2spec
will ensure that the server executable is killed when h2spec finishes,
de-interleaves h2spec & example server stdout
2017-09-27 14:20:08 -07:00
Eliza Weisman
a54b89a84f Run h2spec on CI (#121) 2017-09-26 12:41:59 -07:00
Oliver Gould
0b289fd55d Fix stream-id double-accounting bug (#112)
Both Recv::open and Rev::recv_headers check new stream ids against the
previously stream id. The second such check fails.

Now, only Recv::open performs stream id checks.

Fixes #110
2017-09-26 10:42:12 -07:00
Carl Lerche
8911ee2a4b Remove h2-test-support crate (#119)
The h2-test-support caused the unstable flag to always be enabled.
2017-09-25 22:28:39 -07:00
Oliver Gould
549d96a36b Only run tests once in CI (#117)
* Only run tests once in CI

We run codecov after successful test runs. This ~doubles the length of
CI jobs, sicne the codecov run reproduces nearly all tests.

To avoid this, we just run the codecov tests as part of our normal test
script.

* s/before_script/install

* only publish coverage after test completes

* run all tests for coverage

* remove hpack from coverage

* fix tyop

* cargo clean
2017-09-25 16:39:55 -07:00