Commit Graph

2438 Commits

Author SHA1 Message Date
Rafael Ávila de Espíndola
1d553e52c6 feat(server): Remove Send + Sync requirement for Body in with_graceful_shutdown
Also expand the single threaded example to use that.
2021-10-12 16:47:03 -07:00
Rafael Ávila de Espíndola
7feab2f3db test(server): Use a !Send and !Sync HttpBody in an example
The default Body type is used in the client in a Pool, so it has to be
Send. On the server, we can use a !Send type if the executor is single
threaded.

Expand the existing example to show that.
2021-10-12 16:47:03 -07:00
Anthony Ramine
6169db250c feat(h2): always include original h2 error on broken pipe 2021-10-04 13:35:07 -07:00
Sean McArthur
ecd5dc1034 docs(contrib): add Minimum Support Rust Version (MSRV) policy 2021-09-21 16:02:04 -07:00
Dai Dao
3908eeb788 docs(examples): updated imports in client_json example (#2412) 2021-09-16 16:34:10 -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
Vagelis Prokopiou
0460cd909e docs(body): add example for to_bytes()
cc #2201
2021-09-16 16:25:40 -07:00
Sean McArthur
e6b2cbda03 docs(dev): start a set of "dev" docs
Initially this creates a top-level "dev" directory to hold documents
pertaining to the development, as opposed to the usage, of hyper. For a
first doc, it splits out the commit guidelines to its own file.

cc #2586
2021-09-16 12:53:59 -07:00
Sean McArthur
6a876b8ed2 v0.14.13 2021-09-16 10:25:36 -07:00
Sean McArthur
949216f583 docs(ffi): expand URI documentation 2021-09-16 10:20:40 -07:00
David Cook
a54689b921 feat(ffi): add hyper_request_set_uri_parts
Add a second FFI interface for setting the URI of a request with three
separate schema, authority, and path/query strings, rather than one URI
string.
2021-09-16 09:55:28 -07:00
Sean McArthur
ea3e228287 fix(server): convert panic to error if Connection::without_shutdown called on HTTP/2 conn 2021-09-15 15:50:49 -07:00
Sean McArthur
c88011da4e fix(client): don't reuse a connection while still flushing
A client connection that read a full response while the request body was
still flushing would see incorrect behavior, since the pool would let it
be checked out again for a new request. In debug builds, it would then
panic, but in release builds it would intermix the 2nd request bytes
with the body of the previous request.

In practice, this only ever happens if a server replies with a full
response before reading the full request, while also choosing to not
close that connection. Most servers either wait for the full request, or
close the connection after the new response is written, so as to stop
reading.
2021-09-15 10:25:17 -07:00
Sean McArthur
e3ab409808 refactor(lints): fix unused warnings in tests/docs 2021-09-14 16:50:22 -07:00
Jonas Platte
0a4b56acb8 feat(lib): Export more things with Cargo features [server, !http1, !http2]
* server::Server
* server::conn::{AddrIncoming, AddrStream}

This allows higher-level libraries to use or re-export more parts of the
API without deciding for the end user which HTTP versions the hyper
server will support.
2021-08-31 16:35:52 -07:00
Jonas Platte
cf6f62c71e feat(lib): Export rt module independently of Cargo features 2021-08-31 16:35:52 -07:00
Jonas Platte
d49c25b224 refactor(server): Merge imports 2021-08-31 16:35:52 -07:00
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