Commit Graph

2522 Commits

Author SHA1 Message Date
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
nickelc
257d6a9919 docs(server): set doc_cfg attributes for tcp feature gated Server methods (#2401) 2021-01-14 13:56:49 -08:00
Taiki Endo
f0ddb66932 refactor(lib): apply unreachable_pub lint (#2400)
Closes #2390
2021-01-14 09:57:55 -08:00
Markus Westerlind
a15f3f7f0f refactor(client): minimize the amount of instantiated code (#2391)
* Halve the amount of conn_task instantiations
* Extract non-generic parts of client::handshake
* Extract the non-generic parts of call_async
2021-01-12 16:18:22 -08:00
Sean McArthur
446dd2f0c7 chore(security): add a SECURITY.md policy (#2395) 2021-01-12 14:45:10 -08:00
Sean McArthur
c9c46ed60b refactor(ffi): Add Reason-Phrase API
This adds an internal ability to copy the HTTP/1 reason-phrase and place
it in the `http::Extensions` of a response, if it doesn't match the
canonical reason. This could be exposed in the Rust API later, but for
now it is only used by the C API.
2021-01-08 10:25:53 -08:00
Sean McArthur
4c32daeea0 refactor(ffi): Add HeaderCaseMap preserving http1 header casing 2021-01-08 10:25:53 -08:00
Sean McArthur
3ae1581a53 feat(ffi): Initial C API for hyper 2021-01-08 10:25:53 -08:00
Sean McArthur
8861f9a786 v0.14.2 2020-12-29 10:51:50 -08:00
Kirill Fomichev
a6d4fcbee6 feat(server): expose Accept without httpX features (#2382) 2020-12-29 10:19:57 -08:00
Maxim Zhukov
510b998ff3 chore(dev-dependencies): bump url to 2.2 (#2379) 2020-12-28 15:52:28 -08:00
Nikhil Benesch
73a59e5fc7 feat(client): expose connect types without proto feature (#2377)
Make it possible to refer to Connected, Connection, HttpConnector, etc.
without enabling either of the http1/http2 features. This makes feature
selection work better for downstream libraries like hyper-openssl, which
don't want to commit to any particular protocol.

Fix #2376.
2020-12-28 15:50:28 -08:00
Sean McArthur
3d6bdbe850 v0.14.1 2020-12-23 13:01:14 -08:00
Sean McArthur
c97a106125 docs(lib): enable doc_cfg on docs.rs builds (#2372) 2020-12-23 12:55:28 -08:00
Sean McArthur
c784a10174 v0.14.0 2020-12-23 10:58:04 -08:00
Sean McArthur
fad42acc79 feat(lib): Upgrade to Tokio 1.0 (#2369)
Closes #2370
2020-12-23 10:36:12 -08:00
Abdullah Eryuzlu
dad5c8792f fix(client): log socket option errors instead of returning error (#2361)
Closes #2359
2020-12-23 07:41:04 -08:00
Pankaj Chaudhary
3b3077da1f refactor(http1): updated Encoder/Decoder match with the matches macro (#2368) 2020-12-22 10:50:57 -08:00
Pawan Singh Bisht
6c593c2925 refactor(error): use matches! macro in Error::is_* methods (#2367) 2020-12-21 12:25:47 -08:00
Alex Rebert
1dd761c87d fix(http1): ignore chunked trailers (#2357)
Previously, hyper returned an "Invalid chunk end CR" error on chunked
responses with trailers, as described in RFC 7230 Section 4.1.2. This
commit adds code to ignore the trailers.

Closes #2171
2020-12-15 14:23:07 -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
Ben Noordhuis
7d9a5806e1 refactor(http1): change HTTP2->1.1 warning to debug (#2354)
We use hyper in a proxy-like way where an incoming HTTP/2 request is
proxied to a HTTP/1 backend and it was reported that the protocol
coercion warnings were a limiting factor in the total throughput
of the system.

While it can be worked around by explicitly setting the request version
to HTTP_11, it seems likely other people also hit this performance snag.
That's why this commit changes them from warnings to debug messages.
2020-12-14 13:57:32 -08:00
Sean McArthur
b4e24332a0 feat(client): change DNS Resolver to resolve to SocketAddrs (#2346)
The DNS resolver part of `HttpConnector` used to require resolving to
`IpAddr`s, and this changes it so that they resolve to `SocketAddr`s.
The main benefit here is allowing for resolvers to set the IPv6 zone ID
when resolving, but it also just more closely matches
`std::net::ToSocketAddrs`.

Closes #1937

BREAKING CHANGE: Custom resolvers used with `HttpConnector` must change
  to resolving to an iterator of `SocketAddr`s instead of `IpAddr`s.
2020-12-03 14:21:19 -08:00
Jim Holmström
3cb6b4e840 docs(examples): gateway: remove extra slash for uri (#2351)
The PathAndQuery already contains the leading slash, which erroneously
sets the proxied path to "//.." and not "/..".
2020-12-03 13:36:32 -08:00
Chris Campbell
f8641733be docs(client): add example of client conn usage (#2350)
Add basic, module level example for the Builder performing a handshake,
spawning a task to run the Connection and sending a single request and
receiving the response.

Closes #2272
2020-12-01 15:58:28 -08:00
Linus Färnstrand
21dea21145 chore(dependencies): upgrade socket2 (#2349)
Upgrades to a version not making invalid assumptions about
the memory layout of std::net::SocketAddr
2020-11-30 05:48:28 -08:00
Robert Clipsham
1ba2a141a6 test(client): Upgrade libpnet depedency to 0.27.2 [#2347] (#2348)
Additionally, only depend on pnet_datalink to reduce compile times.

Closes #2347
2020-11-27 21:55:03 -08:00
Sean McArthur
a470446deb chore(error): remove undocumented public error module (#2344) 2020-11-25 12:52:07 -08:00
Michael Hewson
db32e1050c feat(lib): remove dependency on tracing's log feature (#2342)
Closes #2326

BREAKING CHANGE: hyper no longer emits `log` records automatically.
  If you need hyper to integrate with a `log` logger (as opposed to `tracing`),
  you can add `tracing = { version = "0.1", features = ["log"] }` to activate them.
2020-11-25 12:41:58 -08:00
Eliza Weisman
d6aadb8300 perf(lib): re-enable writev support (#2338)
Tokio's `AsyncWrite` trait once again has support for vectored writes in
Tokio 0.3.4 (see tokio-rs/tokio#3149).

This branch re-enables vectored writes in Hyper for HTTP/1. Using
vectored writes in HTTP/2 will require an upstream change in the `h2`
crate as well.

I've removed the adaptive write buffer implementation
that attempts to detect whether vectored IO is or is not available,
since the Tokio 0.3.4 `AsyncWrite` trait exposes this directly via the
`is_write_vectored` method. Now, we just ask the IO whether or not it
supports vectored writes, and configure the buffer accordingly. This
makes the implementation somewhat simpler.

This also removes `http1_writev()` methods from the builders. These are
no longer necessary, as Hyper can now determine whether or not
to use vectored writes based on `is_write_vectored`, rather than trying
to auto-detect it.

Closes #2320 

BREAKING CHANGE: Removed `http1_writev` methods from `client::Builder`,
  `client::conn::Builder`, `server::Builder`, and `server::conn::Builder`.
  
  Vectored writes are now enabled based on whether the `AsyncWrite`
  implementation in use supports them, rather than though adaptive
  detection. To explicitly disable vectored writes, users may wrap the IO
  in a newtype that implements `AsyncRead` and `AsyncWrite` and returns
  `false` from its `AsyncWrite::is_write_vectored` method.
2020-11-24 10: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
Eliza Weisman
751c122589 feat(lib): update bytes to 0.6, update http-body (#2339)
This branch updates `bytes` and `http-body` to the latest versions. The
`http-body` version that uses `bytes` 0.6 hasn't been released yet, so
we depend on it via a git dep for now. Presumably Hyper and `http-body`
will synchronize their releases.

Other than that, this is a pretty mechanical update. Should fix the
build and unblock the `h2` update to use vectored writes.
2020-11-19 16:23:32 -08:00
Sean McArthur
ed2b22a7f6 feat(lib): disable all optional features by default (#2336)
BREAKING CHANGE: All optional features have been disabled by default.
2020-11-19 10:05:39 -08:00
Eliza Weisman
abb6471690 refactor(client): use tokio's TcpSocket for more sockopts (#2335)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-18 14:45:45 -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
eb092a7b8c chore(ci): check all feature combinations in CI 2020-11-17 14:30:27 -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
2f2ceb2426 chore(ci): automatically publish benchmarks in a graph 2020-11-16 16:51:30 -08:00
Eliza Weisman
b3b8010e1c refactor(server): simplify drain (#2328)
The current implementation of `drain` uses a `tokio::sync::watch`
channel to send the shutdown signal, and a `tokio::sync::mpsc` to signal
when all draining tasks have completed. No data is ever actually sent on
the MPSC; instead, it is simply used to notify the task that signalled
the drain when all draining tasks have been dropped.

Tokio 0.3's `watch::Sender` has a `closed` method that can be used to
await the dropping of all receivers. This can be used instead of the
MPSC channel. This commit updates `drain` to use `watch::Sender::closed`
instead. This has fewer moving parts, and may have slightly less
overhead (as it doesn't require additional allocation forthe MPSC which
is never actually used).

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-12 13:34:19 -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
Evan Cameron
5438e9b7bf docs(example): fix http_proxy comment (#2324) 2020-11-09 08:07:12 -08:00
Eliza Weisman
71f3402421 fix(http1): ending close-delimited body should close (#2322)
Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-06 15:38:01 -08:00
Sean McArthur
1b9af22fa0 Tokio 0.3 Upgrade (#2319)
Co-authored-by: Urhengulas <johann.hemmann@code.berlin>
Co-authored-by: Eliza Weisman <eliza@buoyant.io>
2020-11-05 17:17:21 -08:00
Sean McArthur
cc7d3058e8 chore(lib): start 0.14.x development 2020-11-02 16:17:15 -08:00
Sean McArthur
42560c7c40 v0.13.9 2020-11-02 15:20:53 -08:00
Pedro Calado
2a938d96ae fix(server): reschedule keep alive interval timer once a pong is received
`KeepAliveState` did not transition from `PingSent` to `Scheduled` after
a pong was received. This prevented more than one ping to be sent by the
server. This fix checks if `ping_sent_at` has already been cleared by
`Ponger::poll` when `KeepAliveState::PingSent` state is active.

Fixes #2310
2020-10-29 09:02:26 -07:00
Pedro Calado
f288641792 test(server): test server keep alive by counting number of pings
Add `http2_keep_alive_count_server_pings` which tests if 3 pings are
received under 5 seconds with keep alive interval set to 1 second.
2020-10-29 09:02:26 -07:00
Ivan Nikulin
fb19f3a869 feat(client): add HttpConnector::set_local_addresses to set both IPv6 and IPv4 local addrs (#2172)
Currently HttpConnector::set_local_address method accepts a single
argument. Server might not support IPv6 or IPv4. Therefore, the only
solution at the moment is to manually perform DNS resolution and pick
appropriate local address family. This is inefficient, as leads to
2 DNS lookups per request. This commit allows specifying both IPv4
and IPv6, so connector can decide which one to use based on DNS
resolution results.
2020-10-13 16:02:16 -07:00