Commit Graph

85 Commits

Author SHA1 Message Date
Anthony Ramine
6a35c175f2 fix(http1): fix preserving header case without enabling ffi (#2820)
The previous commit broke this, but it wasn't released, so released versions will never notice the breakage.
2022-04-26 08:24:57 -07:00
cui fliter
89598dfcfe docs(lib): fix some typos (#2818)
Signed-off-by: cuishuang <imcusg@gmail.com>
2022-04-25 11:05:48 -07:00
Liam Warfield
78de8914ea feature(ffi): add connection option to preserve header order (#2798)
Libcurl expects that headers are iterated in the same order that they
are recieved. Previously this caused curl tests 580 and 581 to fail.
This necessitated exposing a way to preserve the original ordering of
http headers.

SUMMARY OF CHANGES: Add a new data structure called OriginalHeaderOrder that
represents the order in which headers originally appear in a HTTP
message. This datastructure is `Vec<(Headername, multimap-index)>`.
This vector is ordered by the order which headers were recieved.
Add the following ffi functions:
- ffi::client::hyper_clientconn_options_set_preserve_header_order : An
     ffi interface to configure a connection to preserve header order.
- ffi::client::hyper_clientconn_options_set_preserve_header_case : An
     ffi interface to configure a connection to preserve header case.
- Add a new option to ParseContext, and Conn::State called `preserve_header_order`.
  This option, and all the code paths it creates are behind the `ffi`
  feature flag. This should not change performance of response parsing for
  non-ffi users.

Closes #2780

BREAKING CHANGE: hyper_clientconn_options_new no longer
  sets the http1_preserve_header_case connection option by default.
  Users should now call
  hyper_clientconn_options_set_preserve_header_case
  if they desire that functionality.
2022-04-23 09:05:37 -07:00
Anthony Ramine
1f0c177b35 feat(http1): implement obsolete line folding (#2734)
The client now has an option to allow parsing responses with obsolete line folding in headers. The option is off by default, since the spec recommends to reject such things if you can.
2022-02-09 12:59:23 -08:00
Anthony Ramine
5ec094caa5 feat(client): implement the HTTP/2 extended CONNECT protocol from RFC 8441 (#2682) 2022-02-07 17:35:34 -08:00
Sean McArthur
bff977b73c feat(http2): add http2_max_send_buf_size option to client and server
This value is like a high-water mark. It applies per stream. Once a
stream has buffered that amount of bytes to send, it won't poll more
data from the `HttpBody` until the stream has been able to flush under
it.
2021-12-09 10:06:14 -08:00
Sean McArthur
a1502e1067 docs(http1): clarify HTTP1 preserve case option 2021-11-16 11:44:21 -08:00
Anthony Ramine
80627141ed feat(http1): Add http1_writev(bool) to client and server Builders
Restore a way to force queue writing strategy.

Closes #2676
2021-11-04 15:29:43 -07:00
Ivan Tham
7757789589 docs(client): add link and cleanup example for hyper::client::conn (#2533) 2021-09-16 16:31:59 -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
Aaron Turon
73bff4e98c feat(client): expose http09 and http1 options on client::conn::Builder (#2611)
These options are currently available on the high-level builder only.

Along the way, rename the setters to follow the public API conventions
and add docs.

Closes #2461
2021-08-04 13:52:35 -07:00
Sean McArthur
8c89a8c166 feat(ffi): add option to get raw headers from response 2021-06-15 08:43:50 -07:00
Jonas Platte
6a6a24030e refactor(lib): Switch from pin-project to pin-project-lite (#2566)
Note the practical affects of this change:

- Dependency count with --features full dropped from 65 to 55.
- Time to compile after a clean dropped from 48s to 35s (on a pretty underpowered VM).

Closes #2388
2021-06-04 14:57:27 -07:00
boxdot
b9916c4101 feat(client): allow to config http2 max concurrent reset streams (#2535)
Setting streams to 0 makes h2 work on wasm platforms without a
`Instant::now` implementation.
2021-05-13 01:24:41 +00:00
Anthony Ramine
dbea7716f1 feat(http1): add options to preserve header casing (#2480)
Decouple preserving header case from FFI:

The feature is now supported in both the server and the client
and can be combined with the title case feature, for headers
which don't have entries in the header case map.

Closes #2313
2021-04-21 09:50:35 -07:00
Anthony Ramine
11345394d9 feat(client): add option to allow misplaced spaces in HTTP/1 responses (#2506) 2021-04-20 14:17:48 -07:00
Anthony Ramine
68d4e4a3db feat(client): allow HTTP/0.9 responses behind a flag (#2473)
Fixes #2468
2021-03-26 11:25:00 -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
7390f026d7 Revert "refactor(lib): Switch from pin-project to pin-project-lite"
This reverts commit 43412a950f.
2021-02-05 15:51:56 -08:00
Jonas Platte
43412a950f refactor(lib): Switch from pin-project to pin-project-lite 2021-01-28 14:09:53 -08:00
Jonas Platte
9dff00425d refactor(lib): Use cfg(all(...)) instead of multiple cfg attributes 2021-01-28 14:09:53 -08:00
Taiki Endo
f0ddb66932 refactor(lib): apply unreachable_pub lint (#2400)
Closes #2390
2021-01-14 09:57:55 -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
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
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
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
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
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
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
Dirkjan Ochtman
aac0e2dd57 refactor(body): use HttpBody with extra bounds instead of Payload trait 2020-05-14 13:26:39 -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
48102d6122 feat(http2): add adaptive window size support using BDP (#2138)
This adds support for calculating the Bandwidth-delay product when using
HTTP2. When a DATA frame is received, a PING is sent to the remote.
While the PING acknoledgement is outstanding, the amount of bytes of all
received DATA frames is accumulated. Once we receive the PING
acknowledgement, we calculate the BDP based on the number of received
bytes and the round-trip-time of the PING. If we are near the current
maximum window size, the size is doubled.

It's disabled by default until tested more extensively.
2020-02-25 16:00:50 -08:00
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