Commit Graph

46 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
Sean McArthur
509672aada feat(client): introduce version-specific client modules (#2906)
This creates `client::conn::http1` and `client::conn::http2` modules,
both with specific `SendRequest`, `Connection`, and `Builder` types.
2022-07-20 14:12:29 -07:00
Jonas Platte
a81c44f2c8 refactor(lib): Import tracing macros per-module
Instead of one #[macro_use] at the crate root.
2021-08-31 16:35:52 -07:00
Markus Westerlind
f01de8e503 refactor(client): Use async/await more (#2437)
* refactor: Use async/await in client.rs

* refactor: Simplify client.rs a bit more

* refactor: Allow !Unpin in Lazy

* Remove some impl Future

* Remove some combinator use
2021-02-18 10:35:43 -08:00
Sean McArthur
4445e736ba refactor(client): fix unused Pin import without http2 2021-02-05 15:51:56 -08:00
Paolo Barbolini
237b2ce083 refactor(lib): Remove useless uses of Pin (#2405) 2021-01-19 14:51:34 -08:00
Taiki Endo
f0ddb66932 refactor(lib): apply unreachable_pub lint (#2400)
Closes #2390
2021-01-14 09:57:55 -08:00
Sean McArthur
fad42acc79 feat(lib): Upgrade to Tokio 1.0 (#2369)
Closes #2370
2020-12-23 10:36:12 -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
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
97ed0478a8 refactor(client): replace futures oneshot with tokio in dispatcher 2020-03-25 14:50:51 -07:00
Sean McArthur
e6a6ddef7c refactor(client): replace futures mpsc for tokio mpsc in dispatcher 2020-03-25 14:50:51 -07:00
danieleades
0eaf304644 style(lib): address most clippy lints 2020-01-03 09:40:32 -08:00
Sean McArthur
0dc89680cd style(lib): run rustfmt and enforce in CI 2019-12-05 13:55:17 -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
Weihang Lo
144893b409 Upgrade some lib tests to async/.await version (#1882)
* test(http): use async/.await

Signed-off-by: Weihang Lo <me@weihanglo.tw>

* test(pool): use async/.await

* test(pool): pass &mut Future into PollOnce

* test(client): tests/benches using async/.await

* test(client): change due to PR #1917

* test(client): change Delay to delay fucntion

Ref: https://github.com/tokio-rs/tokio/pull/1440

* test(client): remove warning triggers
2019-09-06 09:54:11 -07:00
Sean McArthur
7b1d6d71b7 refactor(lib): fix many lint warnings 2019-08-21 11:58:02 -07:00
lzutao
fc7f81b67c style(lib): use rust 2018 edition idioms (#1910) 2019-08-21 11:22:07 -07:00
Sean McArthur
5da17df97f chore(lib): individually disable tests and examples that aren't updated 2019-07-12 13:44:03 -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
50198851a2 fix(http2): correctly propagate HTTP2 request cancellation 2019-06-03 14:39:35 -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
ce2b540f9d chore(client): adjust dispatch giver throughput benchmark generics 2019-02-25 17:35:46 -08:00
Sean McArthur
1e6603353e perf(http2): don't register callback with main h2 client task 2019-02-25 17:27:51 -08:00
Sean McArthur
5e3b43af09 fix(client): prevent a checkout loop of pooled connections that aren't ready yet 2018-04-30 14:06:12 -07:00
Sean McArthur
604ebfbf6f perf(client): reduce an allocation per http2 connection 2018-04-25 16:40:34 -07:00
Sean McArthur
6906ced872 fix(client): handle race condition when sending while connection is closing 2018-04-24 13:58:10 -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
5d3c472228 feat(error): revamp hyper::Error type
**The `Error` is now an opaque struct**, which allows for more variants to
be added freely, and the internal representation to change without being
breaking changes.

For inspecting an `Error`, there are several `is_*` methods to check for
certain classes of errors, such as `Error::is_parse()`. The `cause` can
also be inspected, like before. This likely seems like a downgrade, but
more inspection can be added as needed!

The `Error` now knows about more states, which gives much more context
around when a certain error occurs. This is also expressed in the
description and `fmt` messages.

**Most places where a user would provide an error to hyper can now pass
any error type** (`E: Into<Box<std::error::Error>>`). This error is passed
back in relevant places, and can be useful for logging. This should make
it much clearer about what error a user should provide to hyper: any it
feels is relevant!

Closes #1128
Closes #1130
Closes #1431
Closes #1338

BREAKING CHANGE: `Error` is no longer an enum to pattern match over, or
  to construct. Code will need to be updated accordingly.

  For body streams or `Service`s, inference might be unable to determine
  what error type you mean to return. Starting in Rust 1.26, you could
  just label that as `!` if you never return an error.
2018-04-10 14:29:34 -07:00
Sean McArthur
625e4daaa1 Revert "refactor(lib): convert to futures 0.2.0-beta (#1470)"
This reverts commit a12f7beed9.

Much sadness 😢.
2018-04-10 12:56:55 -07:00
Sean McArthur
7c12a2cde3 fix(client): ensure idle connection is pooled before response body finishes 2018-04-05 22:20:05 -07:00
Sam Rijs
a12f7beed9 refactor(lib): convert to futures 0.2.0-beta (#1470) 2018-03-29 13:32:44 -07:00
Sean McArthur
5db85316a1 refactor(client): replace signal mod with want crate 2018-03-19 11:43:47 -07:00
Sam Reis
27b8db3af8 feat(lib): convert to use tokio 0.1
BREAKING CHANGE: All uses of `Handle` now need to be new-tokio `Handle`.

Co-authored-by: Sean McArthur <sean@seanmonstar.com>
2018-03-19 11:43:47 -07:00
Sean McArthur
26ec18a282 refactor(client): make conn::ResponseFuture implement Send 2018-03-13 16:34:12 -07:00
Sean McArthur
1207c2b624 feat(client): introduce lower-level Connection API
Closes #1449
2018-03-07 14:26:52 -08:00
Sean McArthur
6244526a5b chore(tests): fix not-compiling tests 2018-02-15 12:55:02 -08:00
Sean McArthur
ee61ea9adf feat(client): Client will retry requests on fresh connections
If a request sees an error on a pooled connection before ever writing
any bytes, it will now retry with a new connection.

This can be configured with `Config::retry_canceled_requests(bool)`.
2018-02-15 12:04:58 -08:00
Sean McArthur
dc619a8fa0 fix(client): detect connection closes as pool tries to use
Currently, if the remote closes the connection at the same time that the
pool selects it to use for a new request, the connection may actually
hang. This fix will now more allow the keep-alive read to check the
socket even when the `Conn` think it's busy.

If the connection was closed before the request write happened, returns
back an `Error::Cancel`, letting the user know they could safely retry
it.

Closes #1439
2018-02-12 18:16:21 -08:00
Sean McArthur
88f01793be fix(client): send an Error::Cancel if a queued request is dropped
Adds `Error::Cancel` variant.
2018-02-07 13:12:33 -08:00
Sean McArthur
648548cfa3 test(client): add benchmarks for new cancelable queue 2018-02-06 12:31:31 -08:00
Sean McArthur
265ad67c86 fix(client): more reliably detect closed pooled connections (#1434) 2018-02-05 09:56:29 -08:00