Commit Graph

1810 Commits

Author SHA1 Message Date
Sean McArthur
f698b03e57 perf(headers): don't allocate to format content-length on 32bit when number is not huge 2018-06-22 11:39:32 -07:00
Sean McArthur
ac1af8d15b perf(headers): switch from fmt to itoa when writing content-length header 2018-06-20 17:19:37 -07:00
Sean McArthur
7d8897537b refactor(lib): improve some trace logs for upgrades 2018-06-19 17:38:03 -07:00
Sean McArthur
9b4083de6b v0.12.2 2018-06-19 11:30:05 -07:00
Sean McArthur
61f31b5a4a doc(client): show spawning a client future, clarify lazy in client example 2018-06-18 17:02:57 -07:00
Sean McArthur
482a5f589e fix(lib): return an error instead of panic if execute fails
If executing an internal task fails, a new variant of `hyper::Error` is
returned to the user, with improved messaging.

If a non-critical task fails to spawn, it no longer panics, instead just
logging a warning.

Closes #1566
2018-06-18 16:01:04 -07:00
Sean McArthur
27db8b0061 feat(client): add set_scheme, set_host, and set_port for Destination
Closes #1564
2018-06-18 15:21:41 -07:00
Sean McArthur
e4ebf44823 chore(tests): change tests to use current_thread runtime 2018-06-18 12:30:56 -07:00
Josh Leeb-du Toit
9a28268b98 feat(http2): Add content_length() value to incoming h2 Body
- Add `Body::Kind::H2` to contain the content length of the body.
- Update `Body::content_length` to return the content length if `Body::Kind` is `H2`, instead of returning `None`.

Reference: #1556, #1557

Closes #1546
2018-06-18 11:50:12 -07:00
Sean McArthur
29a8074689 chore(dependencies): update want to 0.0.5 2018-06-14 13:41:03 -07:00
Sean McArthur
fea29b29e2 feat(http1): Add higher-level HTTP upgrade support to Client and Server (#1563)
- Adds `Body::on_upgrade()` that returns an `OnUpgrade` future.
- Adds `hyper::upgrade` module containing types for dealing with
  upgrades.
- Adds `server::conn::Connection::with_upgrades()` method to enable
  these upgrades when using lower-level API (because of a missing
  `Send` bound on the transport generic).
- Client connections are automatically enabled.
- Optimizes request parsing, to make up for extra work to look for
  upgrade requests.
  - Returns a smaller `DecodedLength` type instead of the fatter
    `Decoder`, which should also allow a couple fewer branches.
  - Removes the `Decode::Ignore` wrapper enum, and instead ignoring
    1xx responses is handled directly in the response parsing code.

Ref #1563 

Closes #1395
2018-06-14 13:39:29 -07:00
Steven Fackler
1c3fbfd6bf feat(h2): implement flow control for h2 bodies
Closes #1548
2018-06-11 11:32:50 -07:00
Laurențiu Nicola
386fc0d70b feat(http2): set Content-Length header on outgoing messages
Closes #1547
2018-06-10 15:22:30 -07:00
Josh Leeb-du Toit
f20afba57d feat(http2): Strip connection headers before sending
Automatically removes "connection" headers before sending over HTTP2.
These headers are illegal in HTTP2, and would otherwise cause errors.

Closes: #1551
2018-06-08 17:31:22 -07:00
Laurențiu Nicola
a0a0fcdd9b feat(body): make Body know about incoming Content-Length
When getting a `Body` from hyper, such as in a client response,
the method `Body::content_length()` now returns a value if the header
was present.

Closes #1545
2018-06-08 13:00:46 -07:00
Sean McArthur
396fe80e76 fix(server): fix debug assert failure when kept-alive connections see a parse error 2018-06-07 15:08:53 -07:00
Sean McArthur
d7ab016676 fix(server): correctly handle CONNECT requests
- In the higher-level `Server` API, since connection upgrades aren't yet
  supported, returning a 2xx response to a `CONNECT` request is a user
  error. A 500 response is written to the client, the connection is
  closed, and an error is reported back to the user.
- In the lower-level `server::Connection` API, where upgrades *are*
  supported, a 2xx response correctly marks the response as the final
  one, instead of trying to parse more requests afterwards.
2018-06-07 14:59:01 -07:00
Steven Fackler
bc5e22f580 feat(error): add Error::cause2 and Error::into_cause
- The `cause2` method adds a `'static` bound, allowing to downcast the error type.
- The `into_cause` method converts an `Error` into its optional cause.

Closes #1542
2018-06-06 13:40:07 -07:00
Sean McArthur
b7a0c2d596 fix(http2): implement graceful_shutdown for HTTP2 server connections
Closes #1550
2018-06-06 13:00:59 -07:00
Sean McArthur
3affe2a0af fix(http2): send trailers if Payload includes them 2018-06-05 17:27:15 -07:00
Steven Fackler
a096799c1b feat(body): add Sender::abort
This allows a client or server to indicate that the body should be cut off
in an abnormal fashion so the server doesn't simply get a "valid" but
truncated body.
2018-06-05 17:09:31 -07:00
Sean McArthur
1e3bc6bf1a chore(examples): fix echo compilation without NLL 2018-06-05 12:33:14 -07:00
Sean McArthur
41291346d0 docs(examples): add comments to the echo example 2018-06-05 12:27:33 -07:00
Sean McArthur
53f4c9dca1 chore(ci): skip building tests on minimum Rust version 2018-06-05 11:41:17 -07:00
Josh Leeb-du Toit
924c6da25b docs(examples): update echo example with functionality from the guide
Update the echo example based on the functionality explained in the
Hyper guide: https://hyper.rs/guides/server/echo

Closes #1528
2018-06-05 11:38:59 -07:00
Sean McArthur
e5118d7eea v0.12.1 2018-06-04 17:10:29 -07:00
Sean McArthur
15188b7c7f feat(client): implement Clone for Destination 2018-06-04 11:35:38 -07:00
Sean McArthur
810435f146 feat(server): add http1_writev config option for servers
Closes #1527
2018-06-04 10:59:07 -07:00
Aaron Riekenberg
7eca445ff9 docs(examples): Update send_file example to use tokio-fs 2018-06-04 09:59:42 -07:00
Yusuke Sasaki
14d9246de2 feat(server): add http1_only configuration
A new configuration http1_only to Builder and Connection are added, which indicates that the upgrading to h2 does not perform when a parsing error occurs.

Fixes #1512.
2018-06-04 09:57:19 -07:00
Sean McArthur
785914e77e chore(body): fix unused import in chunk benchmarks 2018-06-04 09:52:54 -07:00
Sean McArthur
185432da1b perf(h1): use faster flattening of body buffers 2018-06-03 16:19:24 -07:00
Sean McArthur
beace2f31e perf(chunk): use faster length check in Chunk::remaining 2018-06-03 16:18:37 -07:00
Yusuke Sasaki
c615a3242f feat(server): add try_into_parts() to conn::Connection (#1531) 2018-06-03 21:43:04 +02:00
Yusuke Sasaki
c6e90b7b65 fix(server): add upgrading process to poll_without_shutdown() (#1530) 2018-06-03 21:41:55 +02:00
Sean McArthur
3abff9a321 docs(changelog): improve breaking changes list with more details 2018-06-03 12:16:09 -07:00
Sean McArthur
497654958e v0.12.0 2018-06-01 15:40:55 -07:00
Sean McArthur
8ea5a46063 chore(lib): merge changelog from 0.11.x branch 2018-06-01 15:28:41 -07:00
Sean McArthur
58004b847c docs(lib): update description of hyper 2018-06-01 15:22:53 -07:00
Sean McArthur
8c393a15c9 chore(ci): disable logs in CI tests 2018-06-01 14:39:16 -07:00
Sean McArthur
5e37272754 docs(server): fix some grammar in Http and Connecting docs 2018-06-01 14:11:32 -07:00
Sean McArthur
789c2231f3 refactor(body): separate body, payload, and chunk into their own internal mods 2018-06-01 11:22:16 -07:00
Sean McArthur
52e1700607 docs(body): hide private __hyper_full_data method from docs 2018-06-01 11:04:19 -07:00
Sean McArthur
898e919504 perf(h1): optimize for when Body is only 1 chunk
- When the `Body` is created from a buffer of bytes (such as
  `Body::from("hello")`), we can skip some bookkeeping that is
  normally required for streaming bodies.
- Orthogonally, optimize encoding body chunks when the strategy
  is to flatten into the headers buf, by skipping the EncodedBuf
  enum.
2018-05-31 19:27:24 -07:00
Sean McArthur
89c5643713 refactor(h1): deref the read buffer only once in server parse 2018-05-31 17:57:34 -07:00
Sean McArthur
72f3ccd7c5 refactor(h1): in debug builds, assert payload known length matchs custom content-length headers 2018-05-31 17:56:27 -07:00
Sean McArthur
bb8cb056fd refactor(h1): collapse some duplicate methods from Cursor 2018-05-31 15:51:27 -07:00
Sean McArthur
8ff42dbbb4 perf(body): move h2 flow control from Chunk to h2 variant of Body 2018-05-31 15:26:04 -07:00
Sean McArthur
5323c2f39c perf(h1): optimize write buffer when flattening 2018-05-30 17:19:45 -07:00
Sean McArthur
bfb2ab8644 perf(server): skip noop AddrStream inner flush 2018-05-30 15:33:36 -07:00