Commit Graph

52 Commits

Author SHA1 Message Date
danieleades
0eaf304644 style(lib): address most clippy lints 2020-01-03 09:40:32 -08:00
Vivek Ghaisas
35825c4614 style(comments): correct some typos in Rust code comments 2019-12-20 10:16:36 -08:00
Sean McArthur
6d2bcef272 perf(upgrade): forward vectored writes on the Upgraded type 2019-12-19 15:33:12 -08:00
Sean McArthur
a07142da2d refactor(client): remove Unpin requirement from request body 2019-12-11 14:18:56 -08:00
Sean McArthur
52cc3f7367 refactor(client): remove Unpin requirement on Body::Data 2019-12-11 14:18:56 -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
Dirkjan Ochtman
de5dcd7865 refactor(lib): use dedicated enums for connection protocol versions
This should make it easier to add H3 functionality.
2019-10-30 14:03:29 -07:00
Sean McArthur
22695968d2 perf(http2): improve default HTTP2 flow control settings
Set default HTTP2 window sizes much larger values than the spec default.

ref #1960
2019-10-08 15:39:35 -07:00
Lucio Franco
eee2a72879 feat(client): provide tower::Service support for clients (#1915) 2019-08-30 12:54:22 -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
lzutao
ae75b3a732 chore(lib): remove async_await feature gate (#1909)
`async_await` is stabilized in rust-lang/rust#63209.
2019-08-21 11:09:14 -07:00
Sean McArthur
7508bd87b0 refactor(client): restore handshake to by-ref 2019-08-19 16:10:57 -07:00
Sean McArthur
41f4173615 refactor(http2): re-enable http2 client and server support 2019-08-19 15:55:49 -07:00
Sean McArthur
1d00bb29d4 chore(client): re-enable client's custom executor config 2019-07-19 14:18:10 -07:00
Weihang Lo
e0c1090ca7 docs(client): send_request doc test to async/await 2019-07-15 11:21:16 -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
01c03db7ea chore(lib): add dyn keyword to trait objects (#1820)
Requires Rust 1.27.
2019-06-03 13:08:13 -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
Vitaly Shukela
edf551b55f feat(client,server) Add Connection::without_shutdown()
* Add `server::conn::Connection::without_shutdown`

  Returns wrapper Future instance which allows
  to use `poll_without_shutdown` method
  more ergonomically.

* Add `client::conn::Connection::without_shutdown`

  Returns wrapper Future instance which allows
  to use `poll_without_shutdown` method
  more ergonomically.

* Improve `poll_without_shutdown` docs

Closes #1786
2019-03-26 15:16:06 -07:00
Kevin Leimkuhler
7dcd4618c0 feat(http2): Add window size config options for Client and Server
Add `fn http2_initial_stream_window_size` and `fn
http2_initial_connection_window_size` for client and server.

Closes #1771
2019-03-01 14:44:38 -08:00
Alexander Mielczarek
078ed82dd5 feat(client): add conn::Builder::max_buf_size()
This allows users to configure a limit to client connections' read and
write buffers.

Closes #1748
2019-01-24 10:59:24 -08:00
Sean McArthur
010a886516 refactor(client): remove dead exec function 2018-12-05 17:01:07 -08:00
Sean McArthur
4b3747110a refactor(client): clean up client config fields 2018-12-05 12:17:03 -08:00
Rick Richardson
2e7250b669 feat(client): add http1_read_buf_exact_size Builder option
This changes the read buffer strategy from being adaptive to always
using an exact size for the buffer.
2018-11-21 14:07:21 -08:00
Sean McArthur
95446cc338 feat(client): add client::conn::Builder::executor method 2018-11-16 16:32:09 -08:00
Sean McArthur
976a77a673 feat(client): add ALPN h2 support for client connectors
- Adds `Connected::negotiated_h2()` method to signal the connection must
  use HTTP2. `Connect` implementations should set this if using ALPN.

If a connection to a host is detected to have been upgraded via ALPN,
any other oustanding connect futures will be canceled, and the waiting
requests will make use of the single HTTP2 connection.

The `http2_only` builder configuration still works the same, not
requiring ALPN at all, and always using only a single connection.
2018-10-31 14:51:29 -07:00
Sean McArthur
09156a70a6 refactor(lib): remove build script features since minimum version is higher 2018-09-28 12:02:21 -07:00
Sean McArthur
5e159a58b4 refactor(client): breakout connect_to future into separate function 2018-09-28 10:24:19 -07:00
Sean McArthur
6e8417e08f refactor(lib): use type macro to detect impl Trait 2018-08-07 21:00:02 -07:00
Niv Kaminer
9f8add6056 chore(client): place the use of new rust features behind cfg 2018-08-07 19:36:00 -07:00
Niv Kaminer
4290b8bba4 perf(client): replace usage of Box<Trait> with impl Trait 2018-08-07 19:36:00 -07:00
Jonas Platte
51223efb8a docs(lib): Fix some typos 2018-07-08 10:10:12 -07:00
Sean McArthur
fea29b29e2 feat(http1): Add higher-level HTTP upgrade support to Client and Server (#1563)
- Adds `Body::on_upgrade()` that returns an `OnUpgrade` future.
- Adds `hyper::upgrade` module containing types for dealing with
  upgrades.
- Adds `server::conn::Connection::with_upgrades()` method to enable
  these upgrades when using lower-level API (because of a missing
  `Send` bound on the transport generic).
- Client connections are automatically enabled.
- Optimizes request parsing, to make up for extra work to look for
  upgrade requests.
  - Returns a smaller `DecodedLength` type instead of the fatter
    `Decoder`, which should also allow a couple fewer branches.
  - Removes the `Decode::Ignore` wrapper enum, and instead ignoring
    1xx responses is handled directly in the response parsing code.

Ref #1563 

Closes #1395
2018-06-14 13:39:29 -07:00
Sean McArthur
26417fc24a perf(h1): improve parsing and encoding of http1 messages 2018-05-15 13:24:58 -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
18c5f640e2 feat(server): add service property to server::conn::Parts
This allows getting the original service back.

Closes #1471

Cherry-pick of commit bf7c0bbf4f55fdf465407874b0b2d4bd748e6783 from the
0.11.x branch.
2018-05-04 13:22:31 +03:00
Sean McArthur
d19d95af77 refactor(client): pass internal executor to h2 dispatcher 2018-04-25 17:55:45 -07:00
Matt Bilker
a02fec8c78 feat(client): add support for title case header names (#1497)
This introduces support for the HTTP/1 Client to write header names as title case when encoding
the request.

Closes #1492
2018-04-24 16:41:02 -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
dfdca25c00 feat(body): rename Entity to Payload
Closes #1464
2018-04-10 15:55:23 -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
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
fbc449e49c feat(body): introduce an Entity trait to represent bodies
This dedicated `Entity` trait replaces the previous `Stream<Item=impl
AsRef<[u8]>, Error=hyper::Error>`. This allows for several improvements
immediately, and prepares for HTTP2 support.

- The `Entity::is_end_stream` makes up for change away from
  `Option<Body>`, which was previously used to know if the body should be
  empty. Since `Request` and `Response` now require a body to be set,
  this method can be used to tell hyper that the body is actually empty.

  It also provides the possibility of slight optimizations when polling
  for data, by allowing to check `is_end_stream` before polling again.
  This can allow a consumer to know that a body stream has ended without
  polling for `None` afterwards.

- The `Entity::content_length` method allows a body to automatically
  declare a size, in case a user doesn't set a `Content-Length` or
  `Transfer-Encoding` header.

- It's now possible to send and receive trailers, though this will be
  for HTTP2 connections only.

By being a trait owned by hyper, new methods can be added later as new
features are wanted (with default implementations).

The `hyper::Body` type now implements `Entity` instead of `Stream`,
provides a better channel option, and is easier to use with custom
streams via `Body::wrap_stream`.

BREAKING CHANGE: All code that was assuming the body was a `Stream` must
  be adjusted to use an `Entity` instead.

  Using `hyper::Body` as a `Stream` can call `Body::into_stream`
  to get a stream wrapper.

  Passing a custom `impl Stream` will need to either implement
  `Entity`, or as an easier option, switch to `Body::wrap_stream`.

  `Body::pair` has been replaced with `Body::channel`, which returns a
  `hyper::body::Sender` instead of a `futures::sync::mpsc::Sender`.

Closes #1438
2018-03-19 11:43:47 -07:00
Sean McArthur
3cd48b45fb feat(lib): replace types with those from http crate
BREAKING CHANGE: `Method`, `Request`, `Response`, `StatusCode`,
  `Version`, and `Uri` have been replaced with types from the `http`
  crate. The `hyper::header` module is gone for now.

  Removed `Client::get`, since it needed to construct a `Request<B>`
  with an empty body. Just use `Client::request` instead.

  Removed `compat` cargo feature, and `compat` related API.
2018-03-19 11:43:47 -07:00