Commit Graph

283 Commits

Author SHA1 Message Date
Michael Fraenkel
d11bb6cd8e http2: dynamic table updates must occur first
Dynamic table size updates must occur at the beginning of the first
header block.

Updates golang/go#25023

Change-Id: I7fd4f191da0a97cab26666545191460a6f6c1433
Reviewed-on: https://go-review.googlesource.com/111681
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-07 19:53:53 +00:00
Brad Fitzpatrick
cbb82b59bc lex/httplex, http/httpguts: merge the httplex package into httpguts
httplex was the original package name for shared code between net/http
and x/net/http2, but its name was too specific, and http/httpguts was
added later for other shared code.

We discussed merging httplex into httpguts at the time, but it didn't
happen earlier. This finishes the move.

Updates golang/go#23908

Change-Id: Ic7d6f39e584ca579d34b5ef5ec6a0c002a38a83c
Reviewed-on: https://go-review.googlesource.com/111875
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-07 19:00:48 +00:00
Thanabodee Charoenpiriyakij
403019bfe6 http2: set nextStreamID to 3 when AllowHTTP is set
Fixes golang/go#25230

Change-Id: Ie16295552fcd414555153626f62170ffb7bdba1d
Reviewed-on: https://go-review.googlesource.com/111835
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-07 17:50:43 +00:00
Mark Fischer
5f9ae10d9a http2: terminate await request cancel goroutine on conn close
If conn closes but the request cancel select is still blocked
we must close the connection wait channel.

Updates golang/go#24776 (needs bundle into std for fix)

Change-Id: I7e3ffdf2dd9b127727e24fe262b2f4c5d96fc184
Reviewed-on: https://go-review.googlesource.com/108415
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-20 17:16:51 +00:00
Baokun Lee
84348c2dc8 http2: don't sniff Content-type in Server when X-Content-Type-Options:nosniff
The header X-Content-Type-Options:nosniff is an explicit directive that
content-type should not be sniffed.

----

https://fetch.spec.whatwg.org/#x-content-type-options-header
defines the X-Content-Type-Options header.

["Polyglots: Crossing Origins by Crossing Formats"](http://citeseerx.ist.psu.edu
/viewdoc/download?doi=10.1.1.905.2946&rep=rep1&type=pdf)
explains Polyglot attacks in more detail.

Fixes golang/go#24795

Change-Id: Ibcc2d6a561394392ad0bf112eecc01c43823a2a2
Reviewed-on: https://go-review.googlesource.com/107295
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-18 02:54:17 +00:00
David Url
a35a21de97 http2, http/httpguts: move ValidTrailerHeader to new common package http/httpguts
Introduce a common package x/net/http/httpguts which can be vendored by
net/http to share detail implementations of the HTTP specification with
x/net/http2.

Updates golang/go#23908

Change-Id: Id5a2d51e05135436cf406c4c4d1b13fca7f84a32
Reviewed-on: https://go-review.googlesource.com/104042
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-16 17:11:10 +00:00
Brad Fitzpatrick
07e8617a6d http2/h2demo: set externalTrafficPolicy to preserve client IPs
So https://http2.golang.org/reqinfo has a RemoteAddr of the client's
actual IP address.

Change-Id: I9db52b2f451ad937d013dd78078e4228e732ffe0
Reviewed-on: https://go-review.googlesource.com/99235
Reviewed-by: David Anderson <danderson@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-07 20:53:06 +00:00
namusyaka
cbe0f9307d all: remove "the" duplications
Change-Id: I5dc9a8fa647ccb34caae9a1342012cb36d1fcc22
Reviewed-on: https://go-review.googlesource.com/94975
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-02-18 17:54:43 +00:00
David Url
dc948dff88 http2: use RFC 723x as normative reference in docs
Replace references to the obsoleted RFC 2616 with references to RFC
7230 through 7235, to avoid unnecessary confusion.

Updates golang/go#21974

Change-Id: Idbe3e73199f0bef9dbdbe1b75c39382799cd646c
Reviewed-on: https://go-review.googlesource.com/94555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-02-15 21:24:50 +00:00
Brad Fitzpatrick
b417086c80 http2/h2demo: pass h2demo tag to gitlock
Change-Id: I1cdb799ce509f94e3541bf3e94cb75b3797269f6
Reviewed-on: https://go-review.googlesource.com/91517
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-02-01 23:25:40 +00:00
Brad Fitzpatrick
d19327ad09 http2/h2demo: enable HTTP ACME challenges, move from CoreOS to Kubernetes
This makes HTTP challenges work on https://http2.golang.org/ since
LetsEncrypted disabled the TLS-SNI challenges.

Also, move it from a systemd unit on CoreOS to GKE.

Updates golang/go#23627
Fixes golang/go#23034

Change-Id: Id8348e9e56ab43e277f1e12d563fd8fc490d6211
Reviewed-on: https://go-review.googlesource.com/91495
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-02-01 22:17:10 +00:00
Kevin Burke
0ed95abb35 all: use HTTPS for iana.org links
iana.org, www.iana.org and data.iana.org all present a valid TLS
certificate, so let's use it when fetching data to avoid errors in
transit.

Change-Id: I1f295442d24a221fe2b722c4782dceee38b960ec
Reviewed-on: https://go-review.googlesource.com/89415
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-24 06:09:56 +00:00
Brad Fitzpatrick
ab555f366c http2: add internal function isNoCachedConnError to test for ErrNoCachedConn
In a given program there may be two separate copies of
ErrNoCachedConn: the h2_bundle.go version in net/http, and the user's
golang.org/x/net/http2 version. We need to be able to detect either
in net/http.

This CL adds a function to report whether an error value represents
that type of error, and then a subsequent CL to net/http will use it
instead of ==.

Updates golang/go#22091

Change-Id: I86f1e20704eee29b8980707b700d7a290107dfd4
Reviewed-on: https://go-review.googlesource.com/87297
Reviewed-by: Tom Bergan <tombergan@google.com>
2018-01-10 23:22:32 +00:00
Brad Fitzpatrick
42fe2e1c20 http2: don't check WriteHeader status if we've already sent the header
Tests will be in net/http in a separate CL.

Updates golang/go#23010

Change-Id: I91a6875b9a59b33a3c669e73dd6632ac523eb9f6
Reviewed-on: https://go-review.googlesource.com/86255
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-05 01:33:40 +00:00
Tom Bergan
894f8ed584 http2: fix flake in net/http's TestCloseIdleConnections_h2
That test makes a request with no body and receives a response with no
body. The client will receive a HEADERS frame with END_STREAM. The test
assumes that the stream is closed immediately on receipt of that HEADERS
frame, i.e., before RoundTrip returns.

This assumption was broken by https://golang.org/cl/70510, which made
stream closure asynchronous w.r.t. RoundTrip.

To fix TestCloseIdleConnections_h2 while preserving the intent of CL
70510, we break processHeaders into two cases:

1. The request has a body. In this case, END_STREAM puts the stream in a
   half-closed-remote state, which means the connection is not
   necessarily idle when RoundTrip returns (since the request body is
   still being uploaded). In this case, we preserve the behavior from CL
   70510.

2. The request does not have a body. In this case, END_STREAM puts the
   stream in a closed state and we must close the stream before
   returning from RoundTrip.

The following command passes when this CL is merged into net/http:
go test -count=100000 -run=TestCloseIdleConnections_h2 net/http

Updates golang/go#22413

Change-Id: Iff2a0685a636ad51bff380e86a42b0d0eea984e5
Reviewed-on: https://go-review.googlesource.com/80139
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-28 22:29:10 +00:00
Gregory Man
6921abc35d http2: discard logger output in invalid response tests
In invalid response tests logger write error messages to stderr and spam
test output.

Since we know response are invalid in these tests we can safely discard
logger output.

Fixes golang/go#22850

Change-Id: Id8c97be910f0cf7dbe2380ba632960364bc8478b
Reviewed-on: https://go-review.googlesource.com/80235
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-28 17:25:51 +00:00
Tom Bergan
e6a4aa30b6 http2: fix leak in activeRes by removing activeRes
AFAICT, activeRes serves no real purpose. It is used in just two ways:

- To reduce the number of calls to closeIfIdle, which reduces the number
  of acquires of cc.mu when there are many concurrent streams. I dug
  through the CL history and could not find any benchmarks showing that
  this is necessary.

- To avoid redundant calls to cs.bufPipe.CloseWithError(err) when a read
  loop is shutdown. This is unnecessary, since redundant CloseWithError
  calls are ignored.

Since there isn't a good reason to have activeRes, the simplest way to
fix the leak is to remove activeRes entirely.

Updates golang/go#21543

Change-Id: I1d1d2dc6c946425a2772c8bf71436707021ac269
Reviewed-on: https://go-review.googlesource.com/80137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-28 01:37:49 +00:00
Tom Bergan
db473f6b23 http2: don't autodetect Content-Type when the response has an empty body
This change was originally made in https://golang.org/cl/46631, however,
that change was applited to net/http/h2_bundle.go instead of x/net/http2.

Updates golang/go#20784

Change-Id: I947fa4c19f3efc400856573768140bece28276a2
Reviewed-on: https://go-review.googlesource.com/80135
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-28 00:57:53 +00:00
Brad Fitzpatrick
d3b7d8cc97 http2: panic on invalid WriteHeader status code
Tests are in net/http. (upcoming CL)

Updates golang/go#22880

Change-Id: Ie94693ad4e14f0c07926a0b6c7827caace94a0aa
Reviewed-on: https://go-review.googlesource.com/80076
Reviewed-by: Tom Bergan <tombergan@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-27 23:23:00 +00:00
Tom Bergan
80e70a3f77 http2: fix race on ClientConn.maxFrameSize
This fixes TestTrailersClientToServer_h2. Before this CL, the following
command reliably fails. With this CL merged into net/http, the following
command reliably succeeds.

go test -race -run=TestTrailersClientToServer_h2 -count 1000 net/http

Updates golang/go#22721

Change-Id: I05d1504c60854fcf3ae9531f36a126e94b00f0b7
Reviewed-on: https://go-review.googlesource.com/79238
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
2017-11-27 21:35:52 +00:00
Brad Fitzpatrick
3e050b2a66 http2: don't crash in Transport on server's DATA following bogus HEADERS
In golang/go#22880, our http2 server was sending a HEADERS response
without a :status header. Our client code correctly returned an error
from RoundTrip, but we forgot to clean up properly, and then
subsequently crashed on a DATA frame.

This fixes the Transport crash. A fix for the server bug will come separately.

Change-Id: Iea3bcf4a8c95963c8b5e2b6dd722177607bd1bc1
Reviewed-on: https://go-review.googlesource.com/80056
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-11-27 21:30:32 +00:00
Brad Fitzpatrick
fb018015d5 http2: don't log about timeouts reading client preface on new connections
Updates golang/go#18776

Change-Id: I7568f779e2b86c72c54c8744c08cc02988dde55b
Reviewed-on: https://go-review.googlesource.com/79498
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-11-22 21:47:05 +00:00
Anmol Sethi
a337091b05 http2: require either ECDSA or RSA ciphersuite
The HTTP/2 RFC does indeed mandate TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
but in practice, people are also using TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
becuase they are only using an ECDSA certificate. This is the case in acme/autocert.

It doesn't make sense to enforce only RSA in cipher suites if it will
never be used because they are using a ECDSA certificate.

Change-Id: I86dac192a3eb9b74e4268310a3b550b3bd88a37f
Reviewed-on: https://go-review.googlesource.com/30721
Reviewed-by: Tom Bergan <tombergan@google.com>
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-07 18:48:41 +00:00
Tom Bergan
01c190206f http2: fix transport data race on reused *http.Request objects
Based on golang/go#19653, it should be possible to reuse an http.Request
object after the outstanding request has completed. This CL fixes a race
in the http/2 library that occurs when a caller tries to reuse an
http.Request just after the request completed.

The new test failed with -race before this CL and passes after this CL.
Verified with -count 10000.

Updates golang/go#21316

Change-Id: I014cf9cefd0dd21f6f41763ba554d23ddc7fca40
Reviewed-on: https://go-review.googlesource.com/75530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-02 19:10:33 +00:00
Tom Bergan
ea0da6f35c http2: remove afterReqBodyWriteError wrapper
There was a case where we forgot to undo this wrapper. Instead of fixing
that case, I moved the implementation of ClientConn.RoundTrip into an
unexported method that returns the same info as a bool.

Fixes golang/go#22136

Change-Id: I7e5fc467f9c26fb74b9b83f2b3b7f8882645e34c
Reviewed-on: https://go-review.googlesource.com/75252
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-01 23:00:25 +00:00
Michael Fraenkel
92447d5589 http2: Discard data reads on HEAD requests
If a server returns a DATA frame while procesing a HEAD request, the
client will discard the data.

Fixes golang/go#22376

Change-Id: Ief9c17ddfe51cc17f7f6326c87330ac9d8b9d3ff
Reviewed-on: https://go-review.googlesource.com/72551
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-10-23 21:56:55 +00:00
Tom Bergan
cd69bc3fc7 http2: always delay closing the connection after sending GOAWAY
Currently, we close the connection immediately after sending a GOAWAY
frame if all outstanding responses have been completely sent. However,
the client may have had requests in-flight at that time which have been
queued in the kernel receive buffer. On both Windows and Linux, if the
connection is close()'d when the receive buffer is not empty, the kernel
sends RST. This has the effect of aborting both sides of the connection,
meaning the client may not actually receive all responses that were sent
before the GOAWAY.

Instead, we should delay calling close() until after the receive buffer
has been drained. We don't want to delay indefinitely, which means we
need some kind of timeout. Ideally that timeout should be about 1 RTT +
epsilon, under the assumption that the client will not send any more
frames after receiving the GOAWAY. However, 1 RTT is difficult to
measure. It turns out we were already using a 1 second delay in other
cases, so we reuse that same delay here.

Note that we do not call CloseWrite() to half-close the underlying TLS
connection. This seems unnecessary -- GOAWAY is effectively a half-close
at the HTTP/2 level.

Updates golang/go#18701 (fixes after it's bundled into net/http)

Change-Id: I4d68bada6369ba95e5db02afe6dfad0a393c0334
Reviewed-on: https://go-review.googlesource.com/71372
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-10-20 20:44:01 +00:00
Anand K. Mistry
1087133bc4 net/http2: reset client stream after processing response headers
When a client receives a HEADER frame with a END_STREAM flag,
clientConn.streamByID closes the stream before processing the headers
which may contain a full non-error response. This causes the request's
bodyWriter cancelation to race with the response.

Closing the stream after processing headers allows the response to be
available before the bodyWriter is canceled.

Updates golang/go#20521

Change-Id: I70740e88f75240836e922163a54a6cd89535f7b3
Reviewed-on: https://go-review.googlesource.com/70510
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-16 23:55:12 +00:00
Mike Appleby
66aacef3dd http2: Respect peer's SETTINGS_MAX_HEADER_LIST_SIZE in ClientConn
Add a new peerMaxHeaderListSize member to ClientConn which records the
SETTINGS_MAX_HEADER_LIST_SIZE requested by the client's peer, and
respect this limit in (*ClientConn) encodeHeaders / encodeTrailers.

Attempting to send more than peerMaxHeaderListSize bytes of headers or
trailers will result in RoundTrip returning errRequestHeaderListSize.

Updates golang/go#13959

Change-Id: Ic707179782acdf8ae543429ea1af7f4f30e67e59
Reviewed-on: https://go-review.googlesource.com/29243
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-08-28 23:17:52 +00:00
Olivier Poitrey
57efc9c3d9 http2: reject DATA frame before HEADERS frame
If the server returns a DATA frame before a HEADERS frame, the client
must close the connection with a PROTOCOL_ERROR as describe in the
section 8.1.2.6.

The current implementation does not reject such sequence and panics
trying to write on the non-initialized bufPipe.

Fixes golang/go#21466

Change-Id: I55755dba259d026529a031e9ff82c915f5e4afae
Reviewed-on: https://go-review.googlesource.com/56770
Reviewed-by: Tom Bergan <tombergan@google.com>
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-24 17:44:28 +00:00
Tom Bergan
1c05540f68 http2: block RoundTrip when the Transport hits MaxConcurrentStreams
Currently if the http2.Transport hits SettingsMaxConcurrentStreams for a
server, it just makes a new TCP connection and creates the stream on the
new connection. This CL updates that behavior to instead block RoundTrip
until a new stream is available.

I also fixed a second bug, which was necessary to make some tests pass:
Previously, a stream was removed from cc.streams only if either (a) we
received END_STREAM from the server, or (b) we received RST_STREAM from
the server. This CL removes a stream from cc.streams if the request was
cancelled (via ctx.Close, req.Cancel, or resp.Body.Close) before
receiving END_STREAM or RST_STREAM from the server.

Updates golang/go#13774
Updates golang/go#20985
Updates golang/go#21229

Change-Id: I660ffd724c4c513e0f1cc587b404bedb8aff80be
Reviewed-on: https://go-review.googlesource.com/53250
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-09 00:05:01 +00:00
Brad Fitzpatrick
167db312be http2/h2i: add flag to dial one ip:port but SNI/:authority like it's another
Change-Id: I35049c37558ddedb9056278c9878f3e3fd6f7f76
Reviewed-on: https://go-review.googlesource.com/53640
Reviewed-by: Avelino <t@avelino.xxx>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-08-08 15:51:37 +00:00
Brad Fitzpatrick
090ebbdfc2 http2: fix Go 1.6 build
We still support Go 1.6 for a few more days. (it'd normally be dropped
after Go 1.9 final is out)

And maybe we'll need to make a special case for supporting it longer
than normal if gRPC needs to.

Change-Id: I78675f1ef26aa09436a70d0f8aa3a0958768dd14
Reviewed-on: https://go-review.googlesource.com/53641
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-08 06:10:10 +00:00
Tom Bergan
945ddfdd3b http2: retry requests after receiving REFUSED STREAM
RoundTrip will retry a request if it receives REFUSED_STREAM. To guard
against servers that use REFUSED_STREAM to encourage rate limiting, or
servers that return REFUSED_STREAM deterministically for some requests,
we retry after an exponential backoff and we cap the number of retries.

The exponential backoff starts on the second retry, with a backoff
sequence of 1s, 2s, 4s, etc, with 10% random jitter.

The retry cap was set to 6, somewhat arbitrarily. Rationale: this is
what Firefox does.

Updates golang/go#20985

Change-Id: I4dcac4392ac4a3220d6d839f28bf943fe6b3fea7
Reviewed-on: https://go-review.googlesource.com/50471
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-08-08 00:11:46 +00:00
Tom Bergan
7b7efd8000 http2/h2i: dump PUSH_PROMISE headers in h2i
Change-Id: Id891991e2b8371ad5744e7a0ec392d9d9bbeefdc
Reviewed-on: https://go-review.googlesource.com/50130
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-20 15:38:33 +00:00
Tobias Klauser
f01ecb60fe http2: fix format argument warnings in tests
Fix two format argument warnings found by vet.

Change-Id: I01d55197c110c2a7486b1bd5dbd0afd74812e535
Reviewed-on: https://go-review.googlesource.com/48090
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-11 18:12:19 +00:00
Tom Bergan
d4223d6710 http2: refund connection flow control on DATA frames received after reset
If the transport had previously sent a RST_STREAM but had not yet
deleted the stream from its list of active streams, we should refund
connection-level flow control for any DATA frame received as such
DATA frames will never be read.

We already refund connection-level flow control if a stream closes with
unread data in bufPipe. However, when we receive a DATA frame after
reset, we don't bother writing it to bufPipe, so we have to refund the
flow control separately.

Updates golang/go#20469

Change-Id: I5a9810a5d6b1bd7e291173af53646246545a6665
Reviewed-on: https://go-review.googlesource.com/46591
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-29 00:07:30 +00:00
Brad Fitzpatrick
fe686d45ea http2: fix Server race
With Tom Bergan.

Updates golang/go#20704

Change-Id: Ib71202801f8c72af2f22865899c93df1f3753fdd
Reviewed-on: https://go-review.googlesource.com/46008
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-06-19 22:59:24 +00:00
Brad Fitzpatrick
973f3f3bbd http2: make Transport treat http.NoBody like it were nil
Updates golang/go#18891

Change-Id: I866862d805dc1757b27817ddb30cf22dc48ac3ff
Reviewed-on: https://go-review.googlesource.com/45993
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-16 20:35:15 +00:00
Brad Fitzpatrick
6b17b9baf5 http2: stop rejecting outgoing paths beginning with two slashes
Updates golang/go#19103 (fixes after bundle into std)

Change-Id: I847133e289e210dedf2b89ab529478edc5de11d1
Reviewed-on: https://go-review.googlesource.com/45773
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-14 20:39:10 +00:00
Brad Fitzpatrick
1a68b1313c http2: fix up comment on unexported connError type
It apparently used to be called connErrorReason but when it was
renamed the comment wasn't updated. Also, the comment was split via a
blank line, detaching it from its decl node.

Change-Id: I4ae510fc0e48fd61f40489428f9da4c6cab3ef2f
Reviewed-on: https://go-review.googlesource.com/45273
Reviewed-by: Hiroshi Ioka <hirochachacha@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-10 00:11:49 +00:00
Tom Bergan
3470a06c13 http2: fix nil dereference after Read completes with an error
Case happens if Read is called after it has already returned an error
previously. Verified that the new TestPipeCloseWithError test fails
before this change but passes after.

Updates golang/go#20501

Change-Id: I636fbb194f2d0019b0722556cc25a88da2d18e13
Reviewed-on: https://go-review.googlesource.com/44330
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-26 18:45:20 +00:00
David Lazar
06b2bf2f14 http2: fix typo in comment
Change-Id: I0febb967cf55118693952332bbb6f740616cfd39
Reviewed-on: https://go-review.googlesource.com/44271
Run-TryBot: David Lazar <lazard@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-26 15:46:59 +00:00
Mikio Hara
5b58a9c3e1 http2/hpack: gofmt -w -s
Change-Id: I7267334f191a6da9929235e79ee71c412e95ed57
Reviewed-on: https://go-review.googlesource.com/44050
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-24 14:36:55 +00:00
Brad Fitzpatrick
d8bd24be36 http2: fix RFC number typo in comment
Fix by Martin Garton in https://golang.org/cl/43370

Change-Id: I5933b136ff667c0f67ec8ebffb52d6f1235232b3
Reviewed-on: https://go-review.googlesource.com/44030
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2017-05-24 03:43:58 +00:00
Tom Bergan
a8e8f92cd6 http2: remove extra goroutine stack from awaitGracefulShutdown
This is a better fix that https://golang.org/cl/43455. Instead of
creating a separate goroutine to wait for the global shutdown channel,
we reuse the new serverMsgCh, which was added in a prior CL.

We also use the new net/http.Server.RegisterOnShutdown method to
register a shutdown callback for each http2.Server.

Updates golang/go#20302
Updates golang/go#18471

Change-Id: Icf29d5e4f65b3779d1fb4ea92924e4fb6bdadb2a
Reviewed-on: https://go-review.googlesource.com/43230
Run-TryBot: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-24 00:03:45 +00:00
Tom Bergan
1a26cf0669 http2: Discard DATA frames from the server after the response body is closed
After a response body is closed, we keep writing to the bufPipe. This
accumulates bytes that will never be read, wasting memory. The fix is to
discard the buffer on pipe.BreakWithError.

Updates golang/go#20448

Change-Id: Ia2cf46cb8c401fd8091ef3785eb48fe7b188bb57
Reviewed-on: https://go-review.googlesource.com/43810
Run-TryBot: Tom Bergan <tombergan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-23 17:53:13 +00:00
Brad Fitzpatrick
5961165da7 http2: mostly test for Transport memory issue
Updates golang/go#20448

Change-Id: I6366b0b0b36d81095ab347ca35e1e72169c05c15
Reviewed-on: https://go-review.googlesource.com/43853
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2017-05-22 23:49:00 +00:00
Dmitri Shuralyov
4dbf598911 http2/hpack: remove unused pair function from package
Move it to a _test.go file instead.

After CL 43190, the pair function is no longer used by the hpack
package, so it can be removed from it. It's still used by tests.

This can help avoid future readers spending time on figuring out
why pair exists in package, but is not used. It can also reduce
chance of the pair function unintentionally being used in the
package (if that needs to happen explicitly, then pair can be
easily moved back to package).

Change-Id: I12ee9b46f57a522bd09e5d0ee22296df4dee1f35
Reviewed-on: https://go-review.googlesource.com/43851
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-22 21:57:58 +00:00
Todd Neal
0d772244c7 http2/hpack: remove pair function and initialize directly
Inlining isn't performed on generated init functions.  Removing the pair
function and initializing the structs directly saves another 16k on a
simple http.ListenAndServe() binary.

delta   name                                      old      new
-58     runtime.findfunctab                       10471    10413         -0.55%
-41     runtime.gcbss                             910      869           -4.51%
41      runtime.gcdata                            612      653            6.70%
-408    runtime.pclntab                           1036311  1035903       -0.04%
-11711  vendor/golang_org/x/net/http2/hpack.init  12283    572          -95.34%

Updates golang/go#6853

Change-Id: Ibccc796fe7403674cf4b4561acf9551d76ff11e8
Reviewed-on: https://go-review.googlesource.com/43190
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-22 19:33:30 +00:00