Commit Graph

24 Commits

Author SHA1 Message Date
Sean McArthur
48102d6122 feat(http2): add adaptive window size support using BDP (#2138)
This adds support for calculating the Bandwidth-delay product when using
HTTP2. When a DATA frame is received, a PING is sent to the remote.
While the PING acknoledgement is outstanding, the amount of bytes of all
received DATA frames is accumulated. Once we receive the PING
acknowledgement, we calculate the BDP based on the number of received
bytes and the round-trip-time of the PING. If we are near the current
maximum window size, the size is doubled.

It's disabled by default until tested more extensively.
2020-02-25 16:00:50 -08:00
Sean McArthur
14fc2d00f1 style(http2): format http2 code 2020-02-19 12:29:59 -08:00
Sean McArthur
cc6b396e65 refactor(h2): change error message when poll capacity is canceled 2020-02-19 11:07:05 -08:00
Sean McArthur
a354580e3f perf(body): reduce memory size of Body by a u64 (#2118)
Replaces the `Option<u64>` content-length with a `DecodedLength`, which
stores its unknown-ness as `u64::MAX`.
2020-01-27 13:09:40 -08:00
danieleades
0eaf304644 style(lib): address most clippy lints 2020-01-03 09:40:32 -08:00
Sean McArthur
245fa9c44c refactor(server): remove Unpin requirement from the Body generic 2019-12-06 13:27:08 -08:00
Sean McArthur
0dc89680cd style(lib): run rustfmt and enforce in CI 2019-12-05 13:55:17 -08:00
Lucio Franco
79c32f8953 feat(body): Update Payload to be a trait alias of http_body::Body (#1908) 2019-08-22 14:13:27 -07:00
Sean McArthur
41f4173615 refactor(http2): re-enable http2 client and server support 2019-08-19 15:55:49 -07:00
Sean McArthur
8f4b05ae78 feat(lib): update to std::future::Future
BREAKING CHANGE: All usage of async traits (`Future`, `Stream`,
`AsyncRead`, `AsyncWrite`, etc) are updated to newer versions.
2019-07-09 15:55:22 -07:00
Sean McArthur
da9b0319ef refactor(lib): update to 2018 edition 2019-07-09 15:16:01 -07:00
Sean McArthur
271bba1667 refactor(error): improve organization of Error kinds
- Placed all cases of "unexpected bytes" errors into the
  `UnexpectedMessage` variant.
- Placed all cases of "unexpected EOF" errors into the
  `IncompleteMessage` variant. Description is now generic about
  "connection closed before message completed", instead of mentioning
  "request" or "response.
- Added `Error::is_incomplete_message()` accessor to help checking for
  unexpected closures.
- Renamed some variants to be clearer when viewing the `Debug` format.
- Collected all "user" errors into an internal `User` enum, to prevent
  forgetting to update the `is_user()` method.
2019-04-26 10:44:40 -07:00
Sean McArthur
fc18b680a5 feat(http2): check Error::source() for an HTTP2 error code to send in reset 2019-03-25 13:10:41 -07:00
Sean McArthur
9b69fa9740 refactor(http2): make several http2 errors more specific 2018-12-11 15:59:35 -08:00
Sean McArthur
ced949cb6b feat(server): allow !Send Servers
Until this commit, servers have required that `Service` and their
`Future` to be `Send`, since the server needs to spawn some internal
tasks to an executor, and by default, that is `tokio::spawn`, which
could be spawning to a threadpool. This was true even if the user were
certain there was no threadpool involved, and was instead using a
different single-threaded runtime, like
`tokio::runtime::current_thread`.

This changes makes all the server pieces generic over an `E`, which is
essentially `Executor<PrivateTypes<Server::Future>>`. There's a new set
of internal traits, `H2Exec` and `NewSvcExec`, which allow for the type
signature to only show the generics that the user is providing. The
traits cannot be implemented explicitly, but there are blanket
implementations for `E: Executor<SpecificType>`. If the user provides
their own executor, it simply needs to have a generic `impl<F>
Executor<F> for MyExec`. That impl can have bounds deciding whether to
require `F: Send`. If the executor does require `Send`, and the
`Service` futures are `!Send`, there will be compiler errors.

To prevent a breaking change, all the types that gained the `E` generic
have a default type set, which is the original `tokio::spawn` executor.
2018-10-16 13:21:45 -07:00
Theodore Cipicchio
24f11a421d fix(http2): allow TE "trailers" request headers
The HTTP/2 spec allows TE headers in requests if the value is
"trailers". Other TE headers are still stripped.

Closes #1642
2018-08-27 10:32:53 -07:00
Josh Leeb-du Toit
ffdb478831 feat(http2): quickly cancel when receiving RST_STREAM
Update Http2 proto to cancel quick when the stream is reset, on an
`RST_STREAM` frame.

Closes: #1549
2018-06-25 11:14:35 -07:00
Steven Fackler
1c3fbfd6bf feat(h2): implement flow control for h2 bodies
Closes #1548
2018-06-11 11:32:50 -07:00
Josh Leeb-du Toit
f20afba57d feat(http2): Strip connection headers before sending
Automatically removes "connection" headers before sending over HTTP2.
These headers are illegal in HTTP2, and would otherwise cause errors.

Closes: #1551
2018-06-08 17:31:22 -07:00
Sean McArthur
3affe2a0af fix(http2): send trailers if Payload includes them 2018-06-05 17:27:15 -07:00
Sean McArthur
a3be110a55 feat(body): change Payload::Data to be a Buf
Closes #1508

BREAKING CHANGE: Each payload chunk must implement `Buf`, instead of
  just `AsRef<[u8]>`.
2018-05-07 10:06:28 -07:00
Sean McArthur
38eba1540f perf(http2): reduce empty EOS frames if end is already known 2018-04-18 16:35:53 -07:00
Sean McArthur
c119097fd0 feat(http2): add HTTP/2 support for Client and Server 2018-04-13 14:23:47 -07:00
Sean McArthur
5027435791 refactor(lib): rename internal http module to proto 2017-09-28 18:28:44 -07:00