Commit Graph

2510 Commits

Author SHA1 Message Date
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
David Pedersen
e79d09396d docs(client): document the guarantees of cloning a Client (#2540)
Small docs improvement to mention that cloning a `Client` is cheap and
will reuse the connection pool.

Fixes https://github.com/hyperium/hyper/issues/2239
2021-05-06 13:48:53 -07:00
Mohsen Alizadeh
d1d2f32a73 docs(headers): no_inline doc on HeaderMap (#2525) 2021-05-03 13:58:34 -07:00
telotic
4e9a006498 docs(example): support requests to domain names in example http_proxy (#2513) 2021-04-28 17:07:03 -07:00
Sean McArthur
963dc23f0d v0.14.7 2021-04-22 09:52:41 -07:00
Anthony Ramine
4fd6c4cb0b feat(server): implement forgotten settings for case preserving 2021-04-22 09:50:46 -07:00
ty
a303b3c329 fix(http1): http1_title_case_headers should move Builder 2021-04-22 09:50:46 -07:00
Sean McArthur
7f69d8f94c v0.14.6 2021-04-21 16:19:31 -07: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
Sean McArthur
117cc492a6 chore(ci): quiet the warnings when verifying the generated header file (#2507) 2021-04-20 17:23:10 -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
Kevin Burke
ed2fdb7b6a chore(ffi): fix compile errors and warnings (#2492)
As I understand it, "cargo rustc" in gen_header.sh generates a ton of
errors, but still manages to generate an object that can be used by
cbindgen to generate hyper.h.

However, I tried to make a separate change to add more fields to
hyper.h, and learned that "cargo rustc" stops if it reaches 50 errors,
which I reached. I was able to buy some headroom and fix a number of
the compilation errors by adding imports to the fake Cargo.toml we
generate in gen_header.sh.

I wasn't sure how to resolve imports like "crate::Result" which appear
to reference the top-level src/error.rs, and print an error when they
are compiled in gen_header.sh. But I only need to buy headroom under
the 50 error count for now, which I was able to do by adding the
imports.

It is possible that someone more familiar with Rust than me could look
at this and know what to change to get the total number of errors to
zero.
2021-04-07 16:12:02 -07:00