Commit Graph

1728 Commits

Author SHA1 Message Date
Laurentiu Nicola
45efba27df feat(body): add From<Box<Stream>> impl for Body 2018-05-02 21:50:37 +03:00
Sean McArthur
ab3c73fd84 fix(http2): force notify h2 client connection when all body streams drop 2018-05-01 12:45:36 -07:00
Sean McArthur
d3e4089062 Merge pull request #1500 from kw217/1498-add-local-bind
feat(client): support local bind for HttpConnector
2018-05-01 11:58:10 -07:00
Keith Wansbrough
b6a3c85d0f feat(client): support local bind for HttpConnector
Add `set_local_address` to the `HttpConnector`.
This configures the client to bind the socket to a local address of
the host before it connects to the destination. This is useful on
hosts which have multiple network interfaces, to ensure the request is
issued over a specific interface.

Closes #1498
2018-05-01 08:35:45 +01:00
Sean McArthur
792b55f5df Merge pull request #1502 from hyperium/tokio-timer
refactor(lib): change from futures-timer to tokio-timer
2018-04-30 20:43:47 -07:00
Sean McArthur
7a7453ba52 refactor(lib): change from futures-timer to tokio-timer 2018-04-30 19:11:05 -07: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
11c92ff467 chore(tests): set a short timeout on the integration clients pool 2018-04-26 12:37:31 -07:00
Sean McArthur
d19d95af77 refactor(client): pass internal executor to h2 dispatcher 2018-04-25 17:55:45 -07:00
Sean McArthur
a4f4553487 chore(ci): enable logs in ci tests again... 2018-04-25 17:04:44 -07:00
Sean McArthur
604ebfbf6f perf(client): reduce an allocation per http2 connection 2018-04-25 16:40:34 -07:00
Sean McArthur
f44fa0e64e chore(body): fix broken import of Chunk internally 2018-04-24 16:57:00 -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
2cd46664d5 docs(body): add more docs for Body and Payload 2018-04-24 16:30:38 -07:00
Sean McArthur
ad74f7a3e0 docs(body): add more details about Chunk 2018-04-24 16:07:09 -07:00
Sean McArthur
34522041dd chore(ci): remove logs from test output 2018-04-24 15:29:19 -07:00
Sean McArthur
988dc7c637 chore(ci): enable logs in tests, publish docs with nightly rustdoc 2018-04-24 14:37:32 -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
d127201ef2 feat(rt): make tokio runtime optional
A Cargo feature `runtime` is added, which is enabled by default, that
includes the following:

- The `client::HttpConnector`, which uses `tokio::net::TcpStream`.
- The `server::AddrStream`, which uses `tokio::net::TcpListener`.
- The `hyper::rt` module, which includes useful utilities to work with
  the runtime without needing to import `futures` or `tokio` explicity.

Disabling the feature removes many of these niceties, but allows people
to use hyper in environments that have an alternative runtime, without
needing to download an unused one.
2018-04-23 16:56:26 -07:00
Ori Avtalion
62a5c1188a docs(README): Use HTTPS, update website link (#1496) 2018-04-22 08:28:58 -07:00
Sean McArthur
21db71914c Merge pull request #1489 from estk/minimum_max_buf_size
Enforce minimum max buf size.
2018-04-20 14:18:00 -07:00
Evan Simmons
aac250f29d fix(server): panic on max_buf_size too small 2018-04-19 12:27:11 -07:00
Sean McArthur
4ea5472f90 perf(http2): improve Body::is_end_stream detection for http2 2018-04-18 16:42:55 -07:00
Sean McArthur
1328412f82 refactor(client): skip some pool housekeeping on shared h2 handles 2018-04-18 16:36:52 -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
a4eb612bd5 tests(http2): add bodies to parallel h2 tests 2018-04-18 16:34:44 -07:00
Sean McArthur
d04ca7b21a Merge pull request #1490 from hyperium/service2
feat(service): introduce hyper-specific `Service`
2018-04-18 14:11:36 -07:00
Sean McArthur
2dc6202fe7 feat(service): introduce hyper-specific Service
This introduces the `hyper::service` module, which replaces
`tokio-service`.

Since the trait is specific to hyper, its associated
types have been adjusted. It didn't make sense to need to define
`Service<Request=http::Request>`, since we already know the context is
HTTP. Instead, the request and response bodies are associated types now,
and slightly stricter bounds have been placed on `Error`.

The helpers `service_fn` and `service_fn_ok` should be sufficient for
now to ease creating `Service`s.

The `NewService` trait now allows service creation to also be
asynchronous.

These traits are similar to `tower` in nature, and possibly will be
replaced completely by it in the future. For now, hyper defining its own
allows the traits to have better context, and prevents breaking changes
in `tower` from affecting hyper.

Closes #1461

BREAKING CHANGE: The `Service` trait has changed: it has some changed
  associated types, and `call` is now bound to `&mut self`.

  The `NewService` trait has changed: it has some changed associated
  types, and `new_service` now returns a `Future`.

  `Client` no longer implements `Service` for now.

  `hyper::server::conn::Serve` now returns `Connecting` instead of
  `Connection`s, since `new_service` can now return a `Future`. The
  `Connecting` is a future wrapping the new service future, returning
  a `Connection` afterwards. In many cases, `Future::flatten` can be
  used.
2018-04-17 17:09:15 -07:00
Sean McArthur
71a15c25f5 Merge pull request #1488 from hyperium/server2
feat(server): re-design `Server` as higher-level API
2018-04-16 16:35:19 -07:00
Sean McArthur
c4974500ab feat(server): re-design Server as higher-level API
The `hyper::Server` is now a proper higher-level API for running HTTP
servers. There is a related `hyper::server::Builder` type, to construct
a `Server`. All other types (`Http`, `Serve`, etc) were moved into the
"lower-level" `hyper::server::conn` module.

The `Server` is a `Future` representing a listening HTTP server. Options
needed to build one are set on the `Builder`.

As `Server` is just a `Future`, it no longer owns a thread-blocking
executor, and can thus be run next to other servers, clients, or
what-have-you.

Closes #1322
Closes #1263

BREAKING CHANGE: The `Server` is no longer created from `Http::bind`,
  nor is it `run`. It is a `Future` that must be polled by an
  `Executor`.

  The `hyper::server::Http` type has move to
  `hyper::server::conn::Http`.
2018-04-16 14:29:19 -07:00
Sean McArthur
35c38cba6e Merge pull request #1487 from tee-too/issue-1473
feat(client): add support to set SO_NODELAY on client HTTP sockets
2018-04-16 09:52:51 -07:00
tee-too
016d79ed26 feat(client): add support to set SO_NODELAY on client HTTP sockets
Add configuration on `HttpConnector` to set `SO_NODELAY` on client
HTTP sockets.

Closes #1473
2018-04-16 13:28:46 +02:00
Sean McArthur
b0f44851ae Merge pull request #1432 from hyperium/h2
Initial HTTP/2 support for Client and Server
2018-04-13 15:10: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
fe1578acf6 feat(client): update construction of Clients
- `Client::new()` no longer needs a `Handle`, and instead makes use of
  tokio's implicit default.
- Changed `Client::configure()` to `Client::builder()`.
- `Builder` is a by-ref builder, since all configuration is now
  cloneable pieces.

BREAKING CHANGE: `Client:new(&handle)` and `Client::configure()` are now
  `Client::new()` and `Client::builder()`.
2018-04-10 17:30:10 -07:00
Sean McArthur
dfdca25c00 feat(body): rename Entity to Payload
Closes #1464
2018-04-10 15:55:23 -07:00
Sean McArthur
313f82d971 Merge pull request #1480 from hyperium/error2
feat(error): revamp `hyper::Error` type
2018-04-10 15:13:57 -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
33874f9a75 Merge pull request #1482 from hyperium/unfutures-02
Revert futures 0.2 changes
2018-04-10 12:57:22 -07:00
Sean McArthur
c210524e94 chore(tests): fix tokio runtime deprecations 2018-04-10 12:56:55 -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
wangcong
72e02d6ac8 docs(conn): remove unnecessary whitespace (#1483) 2018-04-08 23:40:16 -07:00
Sean McArthur
21ba669b34 chore(dependencies): pin to a git commit of futures 0.2.0-beta 2018-04-06 19:09:58 -07:00
Sean McArthur
7b99ccb0f2 chore(dependencies): pin to futures =0.2.0-beta 2018-04-06 18:47:37 -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
06405c2c49 chore(dependencies): move to futures master (#1478) 2018-04-03 11:27:22 -07:00
Sean McArthur
c1f84af481 refactor(client): notify idle interval when pool drops 2018-04-02 10:34:34 -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
Sean McArthur
06f0126fad refactor(lib): clean up unused dependencies 2018-03-19 11:43:47 -07:00