Commit Graph

2269 Commits

Author SHA1 Message Date
Sean McArthur
523d66a41f refactor(body): fix unused sync_wrapper when stream feature disabled (#2287) 2020-09-21 13:57:58 -07:00
Sean McArthur
aea9c52808 v0.13.8 2020-09-18 10:44:16 -07:00
Sean McArthur
d8622e570c refactor(http1): include bytes in invalid header name panic (#2286) 2020-09-18 10:08:44 -07:00
Snarpix
187c22afb5 feat(lib): Setting http1_writev(true) will now force writev queue usage
Previously, calling `http1_writev(true)` would just keep the default behavior, which was to auto detect if writev was optimal. Now, the auto-detection is still default, but explicitly calling `http1_writev(true)` will skip the auto-detection, and always use writev queue strategy.

Closes #2282
2020-09-18 09:50:43 -07:00
Sean McArthur
1edf2af377 docs(client): fix broken intra doc link for http::Uri 2020-09-17 13:44:50 -07:00
Danilo Bargen
58a25eb7dc docs(body): Sender: Add a note about abnormal body closing (#2283) 2020-09-17 11:16:20 -07:00
Stefano Buliani
66fc127c8d docs(server): Example for conn modules (#2277)
Add basic, module-level example for the Http struct in the server::conn module that shows how to customize the configuration of the HTTP protocol handling and then serve requests received through a tokio TCP stream.
2020-08-28 11:21:33 -07:00
João Oliveira
1ecbcbb119 fix(http1): return error if user body ends prematurely
- update proto::h1::end_body to return Result<()>
- update Encoder::end to return Error(NotEof) only when there's Content-length left to be addressed

Closes #2263
2020-08-12 14:12:48 -07:00
Sean McArthur
3de81c822e refactor(h1): add spans for parse_headers and encode_headers (#2262) 2020-08-05 13:52:52 -07:00
João Oliveira
6e7e4e2cd5 docs(client): clarify HttpConnector::new_with_resolver doc (#2255)
link to hyper::client::connect::dns, closes #2254
2020-07-29 09:27:46 -07:00
Sean McArthur
25a05894b9 refactor(h1): use httpdate for server date header 2020-07-28 17:48:32 -07:00
Sean McArthur
48f04b6217 test(h1): add benchmarks for server date checking and rendering 2020-07-28 17:14:15 -07:00
JohnMartin95
f4f14b30e3 chore(dependencies): require tokio 0.2.11 (#2252)
Closes #2250
2020-07-28 16:49:09 -07:00
Theodore DeRego
b5d5e21449 feat(server): implement AsRawFd for AddrStream (#2246)
Fixes #2245.
2020-07-16 08:26:46 -07:00
Sean McArthur
4216b2de70 v0.13.7 2020-07-13 17:03:48 -07:00
Sean McArthur
8f6d0a2f7e docs(readme): replace irc links with discord links 2020-07-10 15:35:02 -07:00
David Barsky
9832aef9ee feat(lib): Move from log to tracing in a backwards-compatible way (#2204)
I've moved Hyper from `log` to `tracing`. Existing `log`-based users shouldn't notice a difference, but `tracing` users will see higher performance when filtering data. This isn't the _end_  of the `tracing` integration that can happen in `Hyper` (e.g., Hyper can start using spans, typed fields, etc.), but _something_ is better than nothing. I'd rather address those points, including examples, in followups.

I've attached a screenshot of the `hello` example working, but the logged information is pulled from `tracing`, not `log`.

<img width="514" alt="Screen Shot 2020-05-16 at 1 23 19 PM" src="https://user-images.githubusercontent.com/2067774/82126298-d8103800-9779-11ea-8f0b-57c632c684d6.png">
2020-07-06 18:30:41 -07:00
Daiki Mizukami
77c3b5bc0c feat(client): impl tower_service::Service for &Client (#2089) 2020-06-25 08:18:05 -07:00
Markus Westerlind
07f2fd1775 refactor(h1): use futures::ready! in a few places 2020-06-23 08:06:39 -07:00
Sean McArthur
981d26d5a1 perf(h2): forward Buf::bytes_vectored to SendBuf 2020-06-16 00:08:37 +00:00
Thomas
55ba000746 docs(service): add example of impl Service (#2209)
Add `examples/service_struct_impl.rs`, which provides an up-to-date
example of implementing MakeService and Service on custom types.
The `Svc` struct has a Counter, which demonstrates how to instantiate
shared resources in the `MakeSvc` and pass the resource to the
services. Updates the `examples/README.md` and the doc in
`src/service/mod.rs`.

Closes #1691
2020-06-15 12:01:04 -07:00
Damien Elmes
0d0d363547 fix(client): don't panic in DNS resolution when task cancelled (#2229)
If the runtime is dropped while a DNS request is being made, it can
lead to a panic. This patch checks if the task was cancelled, and
returns a generic IO error instead of panicking in that case.

The following code reproduces the problem on my macOS machine:

```
use hyper::Client;
use tokio::runtime;

type Result<T> = std::result::Result<T, Box<dyn std::error::Error + Send + Sync>>;

fn main() {
    let rt = runtime::Builder::new()
        .threaded_scheduler()
        .core_threads(1)
        .enable_all()
        .build()
        .unwrap();

    // spawn a request and then drop the runtime immediately
    rt.spawn(fetch_url());
}

async fn fetch_url() -> Result<()> {
    let url: hyper::Uri = "http://example.com".parse()?;
    let client = Client::builder().build_http::<hyper::Body>();

    let res = client.get(url).await?;
    println!("Response: {}", res.status());

    Ok(())
}
```
2020-06-11 13:36:17 -07:00
Taiki Endo
9998f0fd0b refactor(lib): remove pin related unsafe code (#2220) 2020-06-08 16:02:14 -07:00
Taiki Endo
d5d09ed753 refactor(lib): Remove uses of pin_project::project attribute (#2219)
pin-project will deprecate the project attribute due to some unfixable
limitations.

Refs: https://github.com/taiki-e/pin-project/issues/225
2020-06-05 16:53:58 -07:00
Geoffry Song
2354a7eec3 feat(http2): configure HTTP/2 frame size in the high-level builders too (#2214)
Oops, I missed this in #2211.
2020-06-02 19:45:12 -07:00
Sean McArthur
b6fb18aee0 v0.13.6 2020-05-29 11:55:20 -07:00
Geoffry Song
b64464562a feat(http2): allow configuring the HTTP/2 frame size
The default of 16K is taken from h2.
2020-05-29 07:37:22 -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
Joshua Nelson
d5b0ee5672 refactor(client): switch from net2 to socket2 (#2206)
net2 was recently deprecated; socket2 is the recommended alternative

Closes #2205
2020-05-18 17:19:38 -07:00
Sean McArthur
6fbb6db876 docs(body): fix resolution error on Body::default 2020-05-18 16:43:31 -07:00
Sean McArthur
ccd7ebdbb1 chore(ci): remove unused .travis directory 2020-05-15 22:07:16 +00:00
Dirkjan Ochtman
aac0e2dd57 refactor(body): use HttpBody with extra bounds instead of Payload trait 2020-05-14 13:26:39 -07:00
Nikolai Kuklin
203621e3be feat(example): read file by chunks in send_file example (#2193) 2020-04-24 13:02:58 -07:00
Bastien Orivel
e08a271eb9 chore(dependencies): Force tokio to be at least 0.2.5 (#2186)
Without this, you can end up with tokio 0.2.4 and hyper 0.13.5 in your
project, leading to a compile error like this:

```
error[E0599]: no method named `try_recv` found for struct `tokio::sync::mpsc::unbounded::UnboundedReceiver<client::dispatch::Envelope<T, U>>` in the current scope
   --> src/client/dispatch.rs:161:26
    |
161 |         match self.inner.try_recv() {
    |                          ^^^^^^^^ method not found in `tokio::sync::mpsc::unbounded::UnboundedReceiver<client::dispatch::Envelope<T, U>>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `hyper`.
```
2020-04-18 08:18:28 -07:00
Sean McArthur
ffb759701c v0.13.5 2020-04-17 12:29:50 -07:00
Sean McArthur
aafeeb7638 refactor(http2): change rtt weighted moving average beta to 1/8 2020-04-16 17:00:20 -07:00
Dillon Amburgey
5f6ce3c733 docs(lib): fix misspelling 2020-03-31 22:01:29 -07:00
Sean McArthur
f329ae0ff9 refactor(benches): add adaptive_window http2 benchmark 2020-03-30 16:28:58 -07:00
Sean McArthur
39a3bc0ea5 refactor(benches): change end_to_end response body default to empty 2020-03-30 16:13:46 -07: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
Sean McArthur
5b3724eeec chore(ci): re-enable minimum rust version (1.39) 2020-03-25 11:33:21 -07:00
Sean McArthur
fce3ddce46 fix(server): fix panic in Connection::graceful_shutdown 2020-03-25 10:28:46 -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
22fcd66241 v0.13.4 2020-03-20 16:13:44 -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
d838d54fdf fix(http1): try to drain connection buffer if user drops Body 2020-03-10 12:57:36 -07:00
Sean McArthur
5b046a1f8f v0.13.3 2020-03-03 15:34:49 -08:00
Sean McArthur
6a1bd055fc refactor(http2): store bdp sampler in Body H2 variant 2020-03-03 14:48:42 -08:00
Sean McArthur
a82fd6c94a feat(client): rename client::Builder pool options (#2142)
- Renamed `keep_alive_timeout` to `pool_idle_timeout`.
- Renamed `max_idle_per_host` to `pool_max_idle_per_host`.
- Deprecated `keep_alive(bool)` due to confusing name. To disable the
  connection pool, call `pool_max_idle_per_host(0)`.
2020-02-27 14:25:06 -08:00