go /
net /
438097d76259d4670fb324c834c2426a7f1946f8 http2: make the Transport write request body data as it's available
Unlike HTTP/1, we now permit streaming the write of a request body as
we read the response body, since HTTP/2's framing makes it possible.
Our behavior however is based on a heuristic: we always begin writing
the request body right away (like previously, and like HTTP/1), but if
we're still writing the request body and the server replies with a
status code over 299 (not 1xx and not 2xx), then we stop writing the
request body, assuming the server doesn't care about it. There is
currently no switch (and hopefully won't be) to force enable this
behavior. In the case where the server replied with a 1xx/2xx and
we're still writing the request body but the server doesn't want it,
the server can do a RST_STREAM, which we respect as before and stop
sending.
Also in this CL:
* adds an h2demo handler at https://http2.golang.org/ECHO to demo it
* fixes a potential flow control integer truncation bug
* start of clientTester type used for the tests in this CL, similar
to the serverTester. It's still a bit cumbersome to write client
tests, though.
* fix potential deadlock where awaitFlowControl could block while
waiting a stream reset arrived. fix it by moving all checks into
the sync.Cond loop, rather than having a sync.Cond check followed
by a select. simplifies code, too.
* fix two data races in test-only code.
Updates golang/go#13444
Change-Id: Idfda6833a212a89fcd65293cdeb4169d1723724f
Reviewed-on: https://go-review.googlesource.com/17310
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
4 files changed