Commit Graph

2521 Commits

Author SHA1 Message Date
Jonas Platte
db57316e14 refactor(lib): Clean up cfg usage 2021-08-31 16:35:52 -07:00
Jonas Platte
07f9208714 refactor(lib): Inline cfg_http1, cfg_http2 macros 2021-08-31 16:35:52 -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
Sean McArthur
165ada34a3 docs(ffi): note that hyper_buf_copy can return NULL on error 2021-08-26 16:48:03 -07:00
Sean McArthur
f46b175bf7 v0.14.12 2021-08-24 16:24:51 -07:00
Sean McArthur
39b6d01aa0 fix(ffi): on_informational callback had no headers 2021-08-19 12:21:17 -07:00
Sean McArthur
adaa8b3f0e chore(dependencies): require httparse 1.5.1 2021-08-19 11:30:41 -07:00
Soveu
95a978344c refactor(http1): use MaybeUninit for parsing with uninitialized headers (#2545)
Closes #2532
2021-08-19 11:10:30 -07:00
Anthony Ramine
be08648e82 fix(http2): improve errors emitted by HTTP2 Upgraded stream shutdown (#2622) 2021-08-19 11:05:26 -07:00
Daniel Stenberg
9a113ed416 docs(capi): fix typo in the upload example build (#2626) 2021-08-19 08:50:21 -07:00
Daniel Stenberg
a1995ee1cb docs(capi): build 'upload' example too by default (#2625) 2021-08-18 14:16:07 -07:00
Sean McArthur
3b26572876 refactor(ffi): check pointer arguments for NULL (#2624)
This changes all the extern C functions in `hyper::ffi` to check passed
pointer arguments for being `NULL` before trying to use them. Before, we
would just assume the programmer had passed a good pointer, which could
result in segmentation faults. Now:

- In debug builds, it will assert they aren't null, and so if they are,
  a message identifying the argument name will be printed and then the
  process will crash.
- In release builds, it will still check for null, but if found, it will
  return early, with a return value indicating failure if the return type
  allows (such as returning NULL, or `HYPERE_INVALID_ARG`).

Closes #2620
2021-08-18 14:15:14 -07:00
Sean McArthur
c35153998e docs(capi): output the hyper_version in the capi examples (#2623) 2021-08-18 10:29:20 -07:00
Jan Verbeek
684f2fa76d fix(http1): apply header title case for consecutive dashes (#2613)
Fix the header title-casing to work with consecutive
dashes. Previously with two dashes in a row the first dash would
uppercase the second dash which would then not count, so
`weird--header` would be cased as `Weird--header` instead of
`Weird--Header`.
2021-08-05 17:00:57 -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
91bbce4ed3 chore(ffi): update gen_header script to use unpretty option 2021-08-04 11:45:03 -07:00
Sean McArthur
9d253d3168 test(client): fix extra semi-colon warning in helper macro 2021-08-04 11:45:03 -07:00
Sean McArthur
54b57c4797 chore(dependencies): remove tower-util dev-dependency (#2603) 2021-07-30 15:07:11 -07:00
David Cook
6393a0cc03 docs(ffi): fix copy-paste error on hyper_waker_wake (#2604) 2021-07-26 11:18:50 -07:00
Sean McArthur
19f38b3e7f v0.14.11 2021-07-21 15:06:07 -07:00
Sean McArthur
0112d35426 refactor(error): mark TransferEncodingInvalid variant only with server feature 2021-07-21 09:11:12 -07:00
0x79756b69
f70c8ffc7b docs(example): add a get query method to params example (#2601) 2021-07-21 09:09:38 -07:00
Anthony Ramine
f51c677dec fix(http2): improve I/O errors emitted by H2Upgraded (#2598)
When a `CONNECT` over HTTP2 has been established, and the user tries to write data right when the peer closes the stream, it will no longer return as a "user error". The reset code is checked, and converted into an appropriate `io::ErrorKind`.
2021-07-21 08:17:05 -07:00
Sean McArthur
090ee08b03 refactor(http1): reject newlines in chunked extensions
We don't really care what bytes are in chunked extensions. We ignore
them until we find a CRLF. However, some other HTTP implementations may
only look for a LF, and forget that chunked requires the CR as well. To
save them from themselves, this makes hyper reject any chunked
extensions that include an LF byte.

This isn't a *bug*. No one ever cares what's in the extensions. This is
meant as a way to help implementations that don't decoded chunked
encoding correctly. This shouldn't affect really anyone in the real
world.
2021-07-21 06:45:54 -07:00
Anthony Ramine
52214f391c fix(client): retry when pool checkout returns closed HTTP2 connection (#2585)
When http2_only is true, we never try to open a new connection if there
is one open already, which means that if the existing connection that
gets checked out of the pool is closed, then the request won't happen.
2021-07-20 17:06:09 -07:00
Anthony Ramine
5243570137 fix(http2): preserve proxy-authenticate and proxy-authorization headers (#2597)
That Proxy-Authenticate and Proxy-Authorization are forbidden over h2
is not actually specified anywhere, plus h2 also supports CONNECT
requests, which are specifically made to do requests over a proxy,
and those proxies may require authentication, sometimes through
Proxy-Authorization.

Note that there is an openwebdocs project that just started to clear
up any MDN-induced confusion in implementations:

	https://github.com/openwebdocs/project/issues/43
2021-07-16 15:48:45 -07:00
Sean McArthur
25d18c0b74 feat(ffi): add hyper_request_on_informational
This defines an extension type used in requests for the client that is
used to setup a callback for receipt of informational (1xx) responses.
The type isn't currently public, and is only usable in the C API.
2021-07-12 15:43:58 -07:00
Sean McArthur
1cd40b7e26 docs(README): update crates.io badge 2021-07-07 11:49:24 -07:00
Sean McArthur
9b69cbc254 v0.14.10 2021-07-07 11:33:08 -07:00
Sean McArthur
1fb719e0b6 fix(http1): reject content-lengths that have a plus sign prefix
The HTTP/1 content-length parser would accept lengths that were prefixed
with a plus sign (for example, `+1234`). The specification restricts the
content-length header to only allow DIGITs, making such a content-length
illegal. Since some HTTP implementations protect against that, and
others mis-interpret the length when the plus sign is present, this
fixes hyper to always reject such content lengths.

See GHSA-f3pg-qwvg-p99c
2021-07-07 11:33:08 -07:00
Sean McArthur
1068b994df fix(http1): protect against overflow in chunked decoder
The HTTP/1 chunked decoder, when decoding the size of a chunk, could
overflow the size if the hex digits were too large. This fixes it by
adding an overflow check in the decoder.

See GHSA-5h46-h7hh-c6x9
2021-07-07 11:33:08 -07:00
Sean McArthur
11cb4725ad refactor(http2): fix unstable name clash of Cursor::remaining 2021-07-07 10:10:08 -07:00
Sean McArthur
13594c377d chore(github): merge duplicate issue templates 2021-06-24 10:23:39 -07:00
Sean McArthur
c60a9dd9c9 chore(github): add issue templates 2021-06-24 10:21:21 -07:00
Sean McArthur
8c89a8c166 feat(ffi): add option to get raw headers from response 2021-06-15 08:43:50 -07:00
Sean McArthur
08b2138e40 refactor(error): add header parse error details in hyper::Error
When a header parse error is because of content-length or
transfer-encoding semantics, include a better error message in the
`hyper::Error`.
2021-06-11 07:15:31 -07:00
Sean McArthur
ea8b0cd86e refactor(error): remove PartialEq derives for error kind enums
Replaced the comparisons with `matches!`. This should reduce a bit of
code generation that isn't really needed.
2021-06-08 05:47:11 -07:00
Sean McArthur
8b71a67413 v0.14.9 2021-06-07 12:52:37 -07:00
bensadiku
55d9a584b1 refactor(http1): return Parse::Internal error if there's an illegal header name or value (#2544) 2021-06-04 15:17:37 -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
Sean McArthur
0d82405a7b refactor(http1): emit trace logs when buffering write data 2021-06-01 18:21:15 -07:00
Sean McArthur
eb0c646395 fix(http1): reduce memory used with flatten write strategy
If the write buffer was filled with large bufs from the user, such that
it couldn't be fully written to the transport, the write buffer could
start to grow significantly as it moved its cursor without shifting over
the unwritten bytes.

This will now try to shift over the unwritten bytes if the next buf
wouldn't fit in the already allocated space.
2021-05-27 09:02:05 -07:00
Sean McArthur
e61b494e3b v0.14.8 2021-05-25 08:12:49 -07:00
Anthony Ramine
5442b6fadd feat(http2): Implement Client-side CONNECT support over HTTP/2 (#2523)
Closes #2508
2021-05-24 18:20:44 +00:00
Geoffry Song
be9677a1e7 feat(http2): allow HTTP/2 requests by ALPN when http2_only is unset (#2527) 2021-05-19 10:01:20 -07:00
Sean McArthur
4cd06bf256 perf(http2): slow adaptive window pings as the BDP stabilizes (#2550)
This introduces a delay to sending a ping to calculate the BDP that
becomes shorter as the BDP is changing, to improve throughput quickly,
but then also becomes longer as the BDP stabilizes, to reduce the amount
of pings sent. This improved the performance of the adaptive window
end_to_end benchmark.

It should also reduce the amount of pings the remote has to deal with,
hopefully preventing hyper from triggering ENHANCE_YOUR_CALM errors.
2021-05-18 14:12:15 -07:00
Adam C. Foltzer
960a69a587 feat(error): add Error::is_parse_too_large and Error::is_parse_status methods (#2538)
The discussion in #2462 opened up some larger questions about more comprehensive approaches to the
error API, with the agreement that additional methods would be desirable in the short term. These
methods address an immediate need of our customers, so I would like to get them in first before we
flesh out a future solution.

One potentially controversial choice here is to still return `true` from `is_parse_error()` for
these variants. I hope the naming of the methods make it clear that the new predicates are
refinements of the existing one, but I didn't want to change the behavior of `is_parse_error()`
which would require a major version bump.
2021-05-12 18:30:28 -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
Sean McArthur
ccba59fb1b docs(common): remove favicon doc from sync_wrapper module (#2548) 2021-05-13 00:51:45 +00:00
David Pedersen
8a05f8eec1 docs(server): add bigger example to server module (#2539)
It can sometimes be tricky to discover where to use `move` closures,
`async move {}`, and `.clone()` when creating a server. This adds a
slightly more bigger example that will hopefully help some.

Fixes https://github.com/hyperium/hyper/issues/2446
2021-05-11 16:56:01 -07:00