Commit Graph

64 Commits

Author SHA1 Message Date
Sean McArthur
bb3af17ce1 feat(client): remove higher-level hyper::Client (#2941)
This removes the following types and methods from hyper:

- `Client`
- `Error::is_connect()`

BREAKING CHANGE: A pooling client is in the hyper-util crate.
2022-08-15 09:15:59 -07:00
Sean McArthur
0c8ee93d7f feat(client,server): remove tcp feature and code (#2929)
This removes the `tcp` feature from hyper's `Cargo.toml`, and the code it enabled:

- `HttpConnector`
- `GaiResolver`
- `AddrStream`

And parts of `Client` and `Server` that used those types. Alternatives will be available in the `hyper-util` crate.

Closes #2856 
Co-authored-by: MrGunflame <mrgunflame@protonmail.com>
2022-07-29 10:07:09 -07:00
Oddbjørn Grødem
ce72f73464 feat(lib): remove stream cargo feature (#2896)
Closes #2855
2022-06-23 15:12:24 -07:00
Sean McArthur
84b78b6c87 fix(http2): received Body::size_hint() now return 0 if implicitly empty (#2715)
An HTTP/2 stream may include a set of headers, and a flag signalling
END-STREAM, even if a `content-length` isn't included. hyper wouldn't
notice, and so the `Body` would report a size-hint of `0..MAX`. hyper
now notices that the stream is ended, and couldn't possibly include any
bytes for the body, and thus will give a size-hint of `0` exactly.
2021-12-06 14:14:41 -08:00
Danilo Bargen
eb0e718696 docs(body): add links to to_bytes and aggregate (#2464)
Since these two functions are not methods on the `Body`, they aren't
very discoverable. So a note in the docs would definitely be helpful.
2021-03-15 15:40:28 -07:00
Jonas Platte
9dff00425d refactor(lib): Use cfg(all(...)) instead of multiple cfg attributes 2021-01-28 14:09:53 -08:00
nickelc
f821ecdd19 docs(body): set doc_cfg attribute for Body::wrap_stream (#2403) 2021-01-15 16:24:03 -08:00
Abdullah Eryuzlu
bf8d74ad1c feat(body): add send_trailers to Body channel's Sender (#2387)
Closes #2260
2021-01-15 10:14:21 -08:00
Sean McArthur
3ae1581a53 feat(ffi): Initial C API for hyper 2021-01-08 10:25:53 -08:00
Arve Knudsen
ede3a6bd9d refactor(http1): move upgrade state from body to head (#2353)
Move state required for protocol upgrades to head
representations, instead of associating it with the body.

Closes #2340.

Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
2020-12-15 07:31:48 -08:00
Sean McArthur
121c33132c feat(upgrade): Moved HTTP upgrades off Body to a new API (#2337)
Closes #2086

BREAKING CHANGE: The method `Body::on_upgrade()` is gone. It is
  essentially replaced with `hyper::upgrade::on(msg)`.
2020-11-19 16:36:12 -08:00
Sean McArthur
bdb5e5d694 feat(server): Make the server code an optional feature (#2334)
cc #2223 

BREAKING CHANGE: The HTTP server code is now an optional feature. To
  enable the server, add `features = ["server"]` to the dependency in
  your `Cargo.toml`.
2020-11-18 11:02:20 -08:00
Sean McArthur
4e55583d30 feat(client): Make client an optional feature
cc #2223

BREAKING CHANGE: The HTTP client of hyper is now an optional feature. To
  enable the client, add `features = ["client"]` to the dependency in
  your `Cargo.toml`.
2020-11-17 17:06:25 -08:00
Sean McArthur
2a19ab74ed feat(http1): Make HTTP/1 support an optional feature
cc #2251

BREAKING CHANGE: This puts all HTTP/1 methods and support behind an
  `http1` cargo feature, which will not be enabled by default. To use
  HTTP/1, add `features = ["http1"]` to the hyper dependency in your
  `Cargo.toml`.
2020-11-17 10:42:20 -08:00
Sean McArthur
b819b428d3 feat(http2): Make HTTP/2 support an optional feature
cc #2251

BREAKING CHANGE: This puts all HTTP/2 methods and support behind an
  `http2` cargo feature, which will not be enabled by default. To use
  HTTP/2, add `features = ["http2"]` to the hyper dependency in your
  `Cargo.toml`.
2020-11-10 13:40:34 -08:00
Sean McArthur
523d66a41f refactor(body): fix unused sync_wrapper when stream feature disabled (#2287) 2020-09-21 13:57:58 -07:00
Danilo Bargen
58a25eb7dc docs(body): Sender: Add a note about abnormal body closing (#2283) 2020-09-17 11:16:20 -07:00
Roland Kuhn
042c770603 feat(body): remove Sync bound for Body::wrap_stream
A stream wrapped into a Body previously needed to implement `Sync` so
that the Body type implements this autotrait as well (which is needed
due to limitations in async/await). Since a stream only offers one
method that is called with an exclusive reference, this type is
statically proven to be Sync already. In theory it should be fine to add
an `unsafe impl Sync`, but this commit instead adds a SyncWrapper to
enlist the compiler’s help in proving that this is (and remains) correct.

This makes it easier to construct response bodies for client code.
2020-05-19 12:57:09 -07:00
Sean McArthur
6fbb6db876 docs(body): fix resolution error on Body::default 2020-05-18 16:43:31 -07:00
Sean McArthur
597cef225e test(body): fix Body size of tests on 32-bit architecture
Closes #2158
2020-03-24 11:56:26 -07:00
Sean McArthur
9a8413d910 feat(http2): add HTTP2 keep-alive support for client and server
This adds HTTP2 keep-alive support to client and server connections
based losely on GRPC keep-alive. When enabled, after no data has been
received for some configured interval, an HTTP2 PING frame is sent. If
the PING is not acknowledged with a configured timeout, the connection
is closed.

Clients have an additional option to enable keep-alive while the
connection is otherwise idle. When disabled, keep-alive PINGs are only
used while there are open request/response streams. If enabled, PINGs
are sent even when there are no active streams.

For now, since these features use `tokio::time::Delay`, the `runtime`
cargo feature is required to use them.
2020-03-20 14:20:45 -07:00
Sean McArthur
6a1bd055fc refactor(http2): store bdp sampler in Body H2 variant 2020-03-03 14:48:42 -08:00
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
dc88204716 fix(body): return exactly 0 SizeHint for empty body (#2122) 2020-01-29 11:55:07 -08:00
Linus Färnstrand
de7418da2f style(lib): use just std instead of ::std in paths (#2101) 2020-01-29 10:25:57 -08:00
Sean McArthur
c4bb4db5c2 fix(http1): only send 100 Continue if request body is polled
Before, if a client request included an `Expect: 100-continue` header,
the `100 Continue` response was sent immediately. However, this is
problematic if the service is going to reply with some 4xx status code
and reject the body.

This change delays the automatic sending of the `100 Continue` status
until the service has call `poll_data` on the request body once.
2020-01-28 17:32:58 -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
4b6099c7aa feat(body): implement HttpBody for Request and Response
When the body type of a `Request` or `Response` implements `HttpBody`,
the `Request` or `Response` itself now implements `HttpBody`.

This allows writing things like `hyper::body::aggregate(req)` instead of
`hyper::body::aggregate(req.into_body())`.

Closes #2067
2019-12-13 10:48:30 -08:00
Sean McArthur
703ac340cb docs(body): fill in documentation of the to_bytes function 2019-12-12 15:26:54 -08:00
Sean McArthur
57ef271500 docs(lib): fix broken intra docs links 2019-12-11 13:23:36 -08:00
Sean McArthur
5a59875742 feat(body): replace Chunk type with Bytes
Closes #1931

BREAKING CHANGE: All usage of `hyper::Chunk` should be replaced with
  `bytes::Bytes` (or `hyper::body::Bytes`).
2019-12-05 17:22:13 -08:00
Sean McArthur
0dc89680cd style(lib): run rustfmt and enforce in CI 2019-12-05 13:55:17 -08:00
Sean McArthur
0b03b73053 feat(lib): rename unstable-stream feature to stream and enable by default
Closes #2034
2019-12-04 17:09:10 -08:00
Sean McArthur
cb3f39c2dc feat(lib): update Tokio, bytes, http, h2, and http-body 2019-12-04 10:56:34 -08:00
Daniel Johnson
71d088d3d0 chore(dependencies): update futures to 0.3.1 2019-11-14 10:04:16 -08:00
Steven Fackler
dc54ee199f feat(body): identify aborted body write errors 2019-09-13 10:38:14 -07:00
Sean McArthur
2b0405c48c refactor(lib): rename 'stream' feature to 'unstable-stream' 2019-09-11 16:09:49 -07:00
Sean McArthur
511ea3889b feat(body): put Stream impl for Body behind stream feature
BREAKING CHANGE: Using a `Body` as a `Stream`, and constructing one via
  `Body::wrap_stream`, require enabling the unstable `stream` feature.
2019-09-05 15:56:58 -07:00
Sean McArthur
3c6f7999cd wip: body typeid full data 2019-08-30 16:23:28 -07:00
Sean McArthur
62a96c077b feat(body): change Sender::send_data to an async fn.
The previous version is renamed to `try_send_data`.

BREAKING CHANGE: Usage of `send_data` should either be changed to
  async/await or use `try_send_data`.
2019-08-30 16:04:07 -07: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
lzutao
fc7f81b67c style(lib): use rust 2018 edition idioms (#1910) 2019-08-21 11:22:07 -07:00
Sean McArthur
b3774bd6d3 chore(dependencies): update h2's trailer signature 2019-08-20 17:34:36 -07:00
Sean McArthur
fc784913a3 chore(dependencies): update to newer h2 2019-08-20 16:24:34 -07:00
Sean McArthur
750ee95a7c chore(body): fix missing SizeHint import 2019-08-19 16:34:37 -07:00
Sean McArthur
41f4173615 refactor(http2): re-enable http2 client and server support 2019-08-19 15:55:49 -07:00
Sean McArthur
a543c8eef2 test(body): remove concat test for Body 2019-07-23 11:07:06 -07:00
Jakub Wieczorek
d683e13ecb test(client): Re-enable the tests/client.rs test
These tests were temporarily disabled during the migration to the
`std::future::Future` type that's part of the stable Rust now.

This commit updates the tests after the breaking changes and makes them
pass again.
2019-07-23 10:22:26 -07:00
Weihang Lo
e6a7e33cf4 docs(body): wrap_stream using futures_util 2019-07-15 11:21:16 -07:00