Commit Graph

96 Commits

Author SHA1 Message Date
Sean McArthur
a8a4cd2be1 add Client config to disable server push
- Adds `Client::builder().enable_push(false)` to disable push
- Client sends a GO_AWAY if receiving a push when it's disabled
2017-09-18 10:49:35 -07:00
Carl Lerche
f84a1bdd1f Notify connection on connection window expansion (#86)
When capacity is released back to the connection and a connection level
window update needs to be sent out, the connection task needs to be
notified in order for the send to actually happen.
2017-09-14 13:50:52 -07:00
Sean McArthur
e2cda1860b fix Body to return errors when there is recv error 2017-09-13 14:32:27 -07:00
Sean McArthur
d0afe30ab3 fix recv connection flow should always use default initial window size 2017-09-13 14:32:27 -07:00
Sean McArthur
f7d14861e5 rustfmt: add trailing commas in match arms, set fn call to block stle (#85) 2017-09-12 19:29:06 -07:00
Oliver Gould
897bf84163 Use rustfmt to enforce consistent formatting
This change adds a .rustfmt.toml that includes ALL supported settings,
12 of which we have overridden to attempt to cater to our own
proclivities.

rustfmt is checked in the rust-nightly CI job.
2017-09-12 22:29:35 +00:00
Carl Lerche
5c0efcf8c4 Ref count stream state and release when final (#73)
Previously, stream state was never released so that long-lived connections
leaked memory.

Now, stream states are reference-counted and freed from the stream slab
when complete.  Locally reset streams are retained so that received frames
may be ignored.
2017-09-10 16:01:19 -07:00
Oliver Gould
17bebe719a Increment stream window capacity when sending window update (#67) 2017-09-08 12:24:06 -07:00
Sean McArthur
09744f38ef add a ReleaseCapacityTooBig variant to UserError 2017-09-07 08:20:03 -07:00
Sean McArthur
452e49dc3e aggregate WINDOW_UPDATE frames until change is over 50% available 2017-09-07 08:20:03 -07:00
Carl Lerche
c122e97127 Refactor errors (#46)
This patch does a bunch of refactoring, mostly around error types, but it also
paves the way to allow `Codec` to be used standalone.

* `Codec` (and `FramedRead` / `FramedWrite`) is broken out into a codec module.
* An h2-codec crate is created that re-exports the frame and codec modules.
* New error types are introduced in the internals:
  * `RecvError` represents errors caused by trying to receive a frame.
  * `SendError` represents errors caused by trying to send a frame.
  * `UserError` is an enum of potential errors caused by invalid usage
    by the user of the lib.
  * `ProtoError` is either a `Reason` or an `io::Error`. However it doesn't
    specify connection or stream level.
  * `h2::Error` is an opaque error type and is the only error type exposed
    by the public API (used to be `ConnectionError`).

There are misc code changes to enable this as well. The biggest is a new "sink"
API for `Codec`. It provides buffer which queues up a frame followed by flush
which writes everything that is queued. This departs from the `Sink` trait in
order to provide more accurate error values. For example, buffer can never fail
(but it will panic if `poll_ready` is not called first).
2017-09-02 11:12:50 -07:00
Carl Lerche
6fd9674759 Validate received content-length header (#43)
If a content-length header is provided, the value should match the sum
of all data frame lengths. If there is a mismatch, then the stream is
reset.
2017-08-31 12:40:02 -04:00
Carl Lerche
2452cc4423 Validate & convert messages before buffering
Malformed requests and responses should immediately result in a
RST_STREAM. To support this, received header frames are validated and
converted to Request / Response values immediately on receipt and before
buffering.
2017-08-30 18:16:21 -04:00
Carl Lerche
9bb34d907a Thread P generic through all 2017-08-30 18:16:21 -04:00
Carl Lerche
11d5f95236 Wire in trailers (#34)
Add send and receive trailer support.
2017-08-25 10:20:47 -07:00
Carl Lerche
b0e6867877 Fix warnings 2017-08-24 15:52:01 -07:00
Carl Lerche
6a6c9665cd Immediately apply initial window size to streams
The initial window size should be applied to streams once they leave the
IDLE state.
2017-08-24 11:03:33 -07:00
Carl Lerche
66dbde92ef Do not reuse next ptr for multiple linked lists
Because, you might think that each linked list has exclusive access to
the next pointer, but then there is an edge case that proves otherwise.
Also, debugging this kind of thing is annoying.
2017-08-23 20:35:53 -07:00
Oliver Gould
f839443ece implement h2::server::Stream::send_reset(Reason) and Body::is_empty() (#22) 2017-08-23 12:48:00 -07:00
Carl Lerche
807d2b7317 Wire in recv flow control (#26) 2017-08-23 11:22:24 -07:00
Carl Lerche
a623ab68b5 New send flow control (#25)
Restructure send flow control such that sending data is always accepted by `Stream`. Data frames will be buffered until there is available window to send them. Producers can monitor the available window capacity to decide if data should be produced.
2017-08-21 13:52:58 -07:00
Carl Lerche
8a15663ed2 Progress towards allowing large writes 2017-08-11 16:57:51 -07:00
Carl Lerche
32d4c2d5a9 Many more changes 2017-08-11 12:00:22 -07:00
Carl Lerche
c439232ed2 Handle more H2 details 2017-08-10 21:08:57 -07:00
Carl Lerche
10fd4ae7ed Wire up trailers 2017-08-10 20:24:52 -07:00
Carl Lerche
e7c07b0b12 More debug output 2017-08-10 13:34:04 -07:00
Carl Lerche
c118f86517 More flow control work 2017-08-09 16:42:55 -07:00
Carl Lerche
dfec401fdf WIP: send flow control 2017-08-09 14:16:32 -07:00
Carl Lerche
f39e983af0 Actually get server working (maybe) 2017-08-09 10:49:49 -07:00
Carl Lerche
8f2b69c280 Get server working again (mostly) 2017-08-09 10:36:03 -07:00
Carl Lerche
26df3a3698 Remove P generic from type 2017-08-08 22:11:11 -07:00
Carl Lerche
8485bf91e7 Start hooking up reset 2017-08-08 13:48:29 -07:00
Carl Lerche
314b7a1848 Wire in PushPromise 2017-08-08 13:32:36 -07:00
Carl Lerche
441a8416c6 Handle the remote returning a protocol error 2017-08-07 22:35:29 -07:00
Carl Lerche
71da8d121f Start hooking up sending data 2017-08-07 21:01:15 -07:00
Carl Lerche
6053ee059d Get receiving data working 2017-08-07 12:48:50 -07:00
Carl Lerche
71acfe3961 Start hooking up data receiving 2017-08-07 12:17:52 -07:00
Carl Lerche
fc0a7eb898 More work 2017-08-04 12:12:22 -07:00
Carl Lerche
74b3852a58 Start working on prioritization 2017-08-03 22:44:19 -07:00
Carl Lerche
dd8412d660 Much work 2017-08-03 15:50:13 -07:00
Carl Lerche
9f9bf85168 More restructuring 2017-08-02 14:48:10 -07:00
Carl Lerche
9d7221e6cf Misc streams cleanup 2017-08-02 13:09:14 -07:00
Carl Lerche
22ebf186c6 Move state into proto::streams 2017-08-02 12:57:49 -07:00
Carl Lerche
341e15769e Move to custom stream storage 2017-08-02 12:55:41 -07:00
Carl Lerche
a3cbf2d7ac Wire up Trailers frame 2017-08-02 11:34:34 -07:00
Carl Lerche
33bdc057d6 Restructure proto
The existing code has been moved out and is being copied back piece / by
piece while restructuring the code to (hopefully) be more manageable.
2017-08-02 09:42:10 -07:00