Commit Graph

2418 Commits

Author SHA1 Message Date
Sean McArthur ff59bb248b docs(ffi): note that hyper_buf_copy can return NULL on error 2021-08-26 16:48:03 -07:00
Sean McArthur 04fc83fc94 v0.14.12 2021-08-24 16:24:51 -07:00
Sean McArthur adb5b84339 fix(ffi): on_informational callback had no headers 2021-08-19 12:21:17 -07:00
Sean McArthur ce98e7e5b4 chore(dependencies): require httparse 1.5.1 2021-08-19 11:30:41 -07:00
Soveu fee7353425 refactor(http1): use MaybeUninit for parsing with uninitialized headers (#2545)
Closes #2532
2021-08-19 11:10:30 -07:00
Anthony Ramine 2dae3fc578 fix(http2): improve errors emitted by HTTP2 Upgraded stream shutdown (#2622) 2021-08-19 11:05:26 -07:00
Daniel Stenberg f051e28772 docs(capi): fix typo in the upload example build (#2626) 2021-08-19 08:50:21 -07:00
Daniel Stenberg 68e3754482 docs(capi): build 'upload' example too by default (#2625) 2021-08-18 14:16:07 -07:00
Sean McArthur 9b2801722f 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 cdebc737e4 docs(capi): output the hyper_version in the capi examples (#2623) 2021-08-18 10:29:20 -07:00
Jan Verbeek 2853c36b6a 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 c4d9b1c057 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 244a372048 chore(ffi): update gen_header script to use unpretty option 2021-08-04 11:45:03 -07:00
Sean McArthur 012011ca81 test(client): fix extra semi-colon warning in helper macro 2021-08-04 11:45:03 -07:00
Sean McArthur 78a009e79f chore(dependencies): remove tower-util dev-dependency (#2603) 2021-07-30 15:07:11 -07:00
David Cook 6e328e5671 docs(ffi): fix copy-paste error on hyper_waker_wake (#2604) 2021-07-26 11:18:50 -07:00
Sean McArthur c5d62462ec v0.14.11 2021-07-21 15:06:07 -07:00
Sean McArthur fba58cdeea refactor(error): mark TransferEncodingInvalid variant only with server feature 2021-07-21 09:11:12 -07:00
0x79756b69 7c317fcfd9 docs(example): add a get query method to params example (#2601) 2021-07-21 09:09:38 -07:00
Anthony Ramine 39ed7bd1dd 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 10a3e2179a 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 5282d7352a 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 4389222e1e 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 514484d2e5 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 4d0e3dffe8 docs(README): update crates.io badge 2021-07-07 11:49:24 -07:00
Sean McArthur 50bf1c1b35 v0.14.10 2021-07-07 11:33:08 -07:00
Sean McArthur 2f35984810 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 7d2d248d84 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 52ccc7145a refactor(http2): fix unstable name clash of Cursor::remaining 2021-07-07 10:10:08 -07:00
Sean McArthur 1c5683b5fe chore(github): merge duplicate issue templates 2021-06-24 10:23:39 -07:00
Sean McArthur f7a552ca99 chore(github): add issue templates 2021-06-24 10:21:21 -07:00
Sean McArthur 7785870dd1 feat(ffi): add option to get raw headers from response 2021-06-15 08:43:50 -07:00
Sean McArthur 53c9a90941 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 b2f16e53c8 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 e8784b4865 v0.14.9 2021-06-07 12:52:37 -07:00
bensadiku 13f73a9e54 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 ec8b952ff8 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 2d49bfccf9 refactor(http1): emit trace logs when buffering write data 2021-06-01 18:21:15 -07:00
Sean McArthur e890938648 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 1963302068 v0.14.8 2021-05-25 08:12:49 -07:00
Anthony Ramine 8a20968ac3 feat(http2): Implement Client-side CONNECT support over HTTP/2 (#2523)
Closes #2508
2021-05-24 18:20:44 +00:00
Geoffry Song 623e355a9f feat(http2): allow HTTP/2 requests by ALPN when http2_only is unset (#2527) 2021-05-19 10:01:20 -07:00
Sean McArthur 5333744f0c 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 ae867c6cba 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 6a3e685ec7 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 4454337062 docs(common): remove favicon doc from sync_wrapper module (#2548) 2021-05-13 00:51:45 +00:00
David Pedersen cecad050e4 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 0bc2f2af15 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 f5a5497bd0 docs(headers): no_inline doc on HeaderMap (#2525) 2021-05-03 13:58:34 -07:00
telotic e08e562011 docs(example): support requests to domain names in example http_proxy (#2513) 2021-04-28 17:07:03 -07:00