Commit Graph

338 Commits

Author SHA1 Message Date
Dmitri Shuralyov
13f9640d40 [release-branch.go1.13] http2/h2demo: remove h2demo build constraint
The build constraint is no longer useful. It doesn't prevent this
package contributing module requirements to x/net, that was already
resolved by carving h2demo into its own module in golang/go#30685.
Few people do go get -u golang.org/x/net/... in GOPATH mode by now,
so there's no need to optimize for avoiding polluting GOPATH/bin.

Removing the build constraint allows the package to be visible and
tested by trybots and builders. It's also simpler.

Updates golang/go#34361

Change-Id: I84b5d70aab210ca8e4f5494160ae4d9049ef08ad
Reviewed-on: https://go-review.googlesource.com/c/net/+/196036
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
(cherry picked from commit a8b05e9114)
Reviewed-on: https://go-review.googlesource.com/c/net/+/198917
2019-10-04 11:05:52 +00:00
Brad Fitzpatrick
7ce5fdcd92 [release-branch.go1.13] http2: fix memory leak in random write scheduler
In certain shutdown cases (from the client and/or server), the http2
Server can Push stream-specific frames on closed streams. This caused
memory leaks in the random write scheduler.

As a conservative fix for backporting, just clear the map element
whenever its queue value is empty. The map entry is re-created as
needed anyway. This isn't perfectly ideal (it adds a map+delete and
free queue put+get) in the case where a stream is open & actively
writing, but it's an easy fix for now. A future CL can optimize all
this code. It looks like there are some other good optimization
opportunities in related code anyway. But I'd rather that happen on
master and not be done in a backported change.

Updates golang/go#34636 (needs bundle to std before fixed)
Updates golang/go#33812

Change-Id: I21508ba2ebc361e8b8532d0d1cebf882e82c473c
Reviewed-on: https://go-review.googlesource.com/c/net/+/198462
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit d98b1b4438)
Reviewed-on: https://go-review.googlesource.com/c/net/+/198617
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
2019-10-04 04:14:01 +00:00
Filippo Valsorda
74dc4d7220 http2: limit number of control frames in server send queue
An attacker could cause servers to queue an unlimited number of PING
ACKs or RST_STREAM frames by soliciting them and not reading them, until
the program runs out of memory.

Limit control frames in the queue to a few thousands (matching the limit
imposed by other vendors) by counting as they enter and exit the scheduler,
so the protection will work with any WriteScheduler.

Once the limit is exceeded, close the connection, as we have no way to
communicate with the peer.

This addresses CVE-2019-9512 and CVE-2019-9514.

Fixes golang/go#33606

Change-Id: I842968fc6ed3eac654b497ade8cea86f7267886b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/525552
Reviewed-by: Brad Fitzpatrick <bradfitz@google.com>
2019-08-13 10:13:03 -04:00
Pascal Dierich
ca1201d0de http2: use updated URI in doc
Fixes golang/go#33246

Change-Id: Iefb39f086eebfa2707725f7464339fca6cff9afd
Reviewed-on: https://go-review.googlesource.com/c/net/+/187277
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2019-07-24 01:30:45 +00:00
Brad Fitzpatrick
461777fb6f http2: support getting the Server connection's base context from net/http
This is the x/net/http2 half of the fix. The net/http half is in CL 181260.

Updates golang/go#32476
Updates golang/go#30694

Change-Id: Ic25c678dad99acc4ae8d679384d9e9a38dc1291c
Reviewed-on: https://go-review.googlesource.com/c/net/+/181259
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-06-07 18:15:51 +00:00
Brad Fitzpatrick
d5cec38845 http2: disable a flaky test on Windows for now, add more logging
Updates golang/go#31260

Change-Id: Icf26461dc48f5f16a91a93df6aa78fec1338f51f
Reviewed-on: https://go-review.googlesource.com/c/net/+/181198
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-06-07 17:21:44 +00:00
Michael Fraenkel
3ec1911272 http2: track reused connections
nextStreamID was used as a means to determine if the connection was
being reused. Multiple requests can see a new connection because the
nextStreamID is updated after a ClientTrace reports it is being reused.

Updates golang/go#31982

Change-Id: Iaa4b62b217f015423cddb99fd86de75a352f8320
Reviewed-on: https://go-review.googlesource.com/c/net/+/176720
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-14 14:07:10 +00:00
Brad Fitzpatrick
a4d6f7fead http2/h2demo: stop using gitlock, use Go modules
Updates golang/go#26872

Change-Id: If2a96708d1fcf43b7ce20a48fa5ae3492f970187
Reviewed-on: https://go-review.googlesource.com/c/net/+/176318
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-05-09 22:28:00 +00:00
marius a. eriksen
1da14a5a36 http2: don't hang a stream if trailers values are not provided
Pre-declared trailers are written after a server's request handler
returns, in which case the trailer header frame is also responsible
for closing the stream. However, if the server handler does not
define a trailer header value before returning, the headers are empty
and no header frame is written. In this case, the stream would simply
hang.

This change fixes this by closing the stream if there are no header
values but endStream is true. Some other options to consider:

1. Reset the stream with an error; the user didn't define a trailer value
   as they said they would. From my brief reading of the http/2 RFC,
   this isn't actually required.
2. Send an explicitly empty header value.

Change-Id: I07e01250df60ac33fa6d34beb81ec2fa7e43c146
GitHub-Last-Rev: dfc532d785
GitHub-Pull-Request: golang/net#31
Reviewed-on: https://go-review.googlesource.com/c/net/+/161958
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-15 21:45:37 +00:00
chigotc
b630fd6fe4 http2/h2i: add port for aix/ppc64
Change-Id: I46758e5685a0eebbe38b0f228fbc084d9ead35b7
Reviewed-on: https://go-review.googlesource.com/c/net/+/170561
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-04-03 14:48:56 +00:00
Michael Fraenkel
74e053c68e http2: make empty method mean GET
We document that "" means "GET" for Request.Method.

Updates golang/go#31061

Change-Id: I41d0c7361e6ad14e9c04c120aed8a30295b1f974
Reviewed-on: https://go-review.googlesource.com/c/net/+/169557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-27 02:57:41 +00:00
Michael Matloob
d888771761 http2/h2demo: require golang.org/x/net@latest
Now that a pseudo-version of golang.org/x/net with h2demo carved exists,
we can depend on it. Add the dependency to h2demo's go.mod file.

Updates golang/go#30685

Change-Id: I3dbb2493d97be381350881228025d27c7e8e8623
Reviewed-on: https://go-review.googlesource.com/c/net/+/166857
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-03-11 18:33:53 +00:00
Michael Matloob
12eef18f75 all: add go.mod files, carve h2demo into separate module
This change adds a go.mod and go.sum file to this repo, following the
requirements stated in bcmills's comment here:
https://golang.org/issue/28136#issuecomment-462971974. It's
important to note that we will not be
adding versions to the repo for now.

This change also creates a new module with the module path
golang.org/x/net/http2/h2demo, and moves the h2demo command into it.
This is done by adding a go.mod file in the http2/h2demo directory.
As a result, the h2demo command and its dependencies are removed
from this and later pseudo-versions of the golang.org/x/net module.

The change was generated using Go 1.12.

Updates golang/go#28136
Fixes golang/go#30685

Change-Id: Ia5b0f6623c3374355b76106432190a0c9acf3d05
Reviewed-on: https://go-review.googlesource.com/c/net/+/162822
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-03-11 17:56:48 +00:00
Brad Fitzpatrick
92fc7df08a http2: remove use of DeepEqual for testing errors
Comparing errors using DeepEqual breaks if frame information
is added as proposed in golang/go#29934.

Updates golang/go#29934

Change-Id: Ia2eb3f5ae2bdeac322b34e12d8e732174b9bd355
Reviewed-on: https://go-review.googlesource.com/c/164517
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2019-02-28 16:57:49 +00:00
zoncoen
fe579d43d8 http2: fix a typo
Change-Id: I7127c3d646042c92fbfbd45e75b08e9b3776d8e9
Reviewed-on: https://go-review.googlesource.com/c/163657
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-02-25 15:36:10 +00:00
Brad Fitzpatrick
65e2d4e150 http2/h2demo: fix the HTTP/1-vs-HTTP/2 demo after HSTS breakage
We were previously demoing HTTP/1 vs HTTP/2 loading performance using
http:// scheme (which uses HTTP/1 implicitly) on the http2.golang.org
domain for HTTP/1, and https://http2.golang.org for HTTP/2.

But then golang.org got into the HSTS preload list, forcing all
*.golang.org to only be HTTPS.

So now, rather than find a new base domain name, to compare against
HTTP/1 we instead use https://http1.golang.org/ and then use the SNI
name to determine whether we advertise "h2".

Also, some cleanup:

* remove launch.go; it's no longer used since we moved to kubernetes
* use a multi-stage Dockerfile rather than the hacky workarounds
  that used to be necessary to simulate multiple stages
* modernize the kubernetes deployment stuff to match how we do
  it elsewhere ("gcloud docker" is long deprecated too)
* update from Go 1.9 to Go 1.11 for the prod base

Fixes golang/go#30033

Change-Id: I9f6b1f496d4005e5a08bf990843d440005a5b3e8
Reviewed-on: https://go-review.googlesource.com/c/160857
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-02-06 17:32:32 +00:00
Michael Fraenkel
ed066c81e7 http2: Revert a closed stream cannot receive data
This reverts CL 111676 for golang/go#25023.

Reason for revert: The code change no longer issued a WindowUpdate which
is required when processing data. The original issue found in golang/go#25023
is not present after the revert.

Updates golang/go#28204

Change-Id: Iadbb63d50ca06df1281e699b9ef13181d0593f80
Reviewed-on: https://go-review.googlesource.com/c/153977
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-01-19 20:41:37 +00:00
Michael Fraenkel
891ebc4b82 http2/hpack: track the beginning of a header block
dynamic table size updates must occur at the beginning of the first
header block. The original fix, golang/go#25023, guaranteed it was at
the beginning of the very first block. The Close method implicitly
marked the end of the current header. We now document the Close behavior
and can track when we are at the beginning of the first block.

Updates golang/go#29187

Change-Id: I83ec39546527cb17d7de8a88ec417a46443d2baa
Reviewed-on: https://go-review.googlesource.com/c/153978
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-12-13 20:27:11 +00:00
Michal Rostecki
6105869963 http2/h2c: Add missing error check
Before this change, error returned by `io.ReadFull` was silently
ignored

Signed-off-by: Michal Rostecki <mrostecki@suse.de>
Change-Id: I6a4604f0c0172a4b951fa4fc99ee83c6ba2ac8d7
Reviewed-on: https://go-review.googlesource.com/c/153137
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-12-07 15:40:23 +00:00
Brad Fitzpatrick
351d144fa1 http2: revert Transport's strict interpretation of MAX_CONCURRENT_STREAMS
And add the http2.Transport.StrictMaxConcurrentStreams bool knob to
behavior being reverted.

In CL 53250 for golang/go#13774 (for Go 1.10) we changed the HTTP/2
Transport's policy such that a server's advertisement of a
MAX_CONCURRENT_STREAMS value meant that it was a maximum for the
entire process, instead of just a single connection.

We thought that was a reasonable interpretation of the spec and
provided nice safety against slamming a server from a bunch of
goroutines doing concurrent requests, but it's been largely
unpopular (see golang/go#27044). It's also different behavior from
HTTP/1 and because you're usually not sure which protocol version
you're going to get, you need to limit your outbound HTTP requests
anyway in case you're hitting an HTTP/1 server.

And nowadays we have the Go 1.11 Transport.MaxConnsPerHost knob too
(CL 71272 for golang/go#13957). It doesn't yet work for HTTP/2, but it
will in either Go 1.12 or Go 1.13 (golang/go#27753)

After this is bundled into net/http's, the default HTTP client will
have this knob set false, restoring the old Go 1.9 behavior where new
TCP connections are created as necessary. Users wanting the strict
behavior and import golang.org/x/net/http2 themselves and make a
Transport with StrictMaxConcurrentStreams set to true. Or they can set
Transport.MaxConnsPerHost, once that works for HTTP/2.

Updates golang/go#27044 (fixes after bundle into std)

Change-Id: I4efdad7698feaf674ee8e01032d2dfa5c2f8a3a8
Reviewed-on: https://go-review.googlesource.com/c/151857
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-12-01 00:20:55 +00:00
Filippo Valsorda
fae4c4e3ad http2: confirm the test fix for golang/go#28762 was correct
Fixes golang/go#28762

Change-Id: I8d8b74cd8836bbed3116b334f6595225a8f0a36e
Reviewed-on: https://go-review.googlesource.com/c/151619
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-29 05:56:19 +00:00
Brad Fitzpatrick
c98d57fa44 http2: disable TLS 1.3 in failing test temporarily(?)
Updates golang/go#28762

Change-Id: If73b292f28e553646431af995942169ce58d43f5
Reviewed-on: https://go-review.googlesource.com/c/149357
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2018-11-13 16:33:21 +00:00
Ruslan Nigmatullin
1c5f79cfb1 http2: don't leak streams on broken body
Updates golang/go#27208

Change-Id: I5d9a643f33d27d33b24f670c98f5a51aa6000967
GitHub-Last-Rev: 3ac4a573b6
GitHub-Pull-Request: golang/net#18
Reviewed-on: https://go-review.googlesource.com/c/132715
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-07 23:42:26 +00:00
Mikio Hara
ab400d30eb http2/h2i: re-adjust build constraints
On Solaris, the MakeRaw and Restore functions of the
x/crypto/ssh/terminal package have been implemented, but on upcoming
platforms such as AIX, Fuchsia and Hurd still have no implementation.

Change-Id: I253249376802273f0160bf3ff1062a66e07b280f
Reviewed-on: https://go-review.googlesource.com/c/147677
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-06 04:01:32 +00:00
Brad Fitzpatrick
22700d5518 http2: remove support for Go 1.8 and earlier
Go's policy is to only support the past two releases (which is
currently Go 1.11 and Go 1.10). But because App Engine was stuck on Go
1.6 and Go 1.8 for so long, we kept kinda supporting Go 1.6 anyway,
even though we didn't actively test it with any CI system.

But that led to code getting disgusting and full of too many
+build-tagged files and indirection, as this change shows.

So, remove Go 1.8, Go 1.7, and Go 1.6 support. We still "support" Go
1.9 for now, even though it's also not actively tested.

Fixes golang/go#26302

Change-Id: I4aa5793173e50ffcd67be52a464492ca48fc9a23
Reviewed-on: https://go-review.googlesource.com/c/145677
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2018-11-01 15:51:06 +00:00
Igor Zhilianin
c44066c5c8 http2: fix typos
Change-Id: Ifa39718a790a7350a0c8f23d21356d42b15e0668
GitHub-Last-Rev: 63d19182f0
GitHub-Pull-Request: golang/net#22
Reviewed-on: https://go-review.googlesource.com/c/145357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-10-29 04:48:18 +00:00
Jongmin Kim
4dfa2610cd all: fix typos in comments
Change-Id: Ic1771d3ea0e26e02f71d5f4d1d458eb93a2c016d
Reviewed-on: https://go-review.googlesource.com/137695
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-26 15:47:20 +00:00
Brad Fitzpatrick
922f4815f7 http2: reduce init-time work & allocations
Updates golang/go#26775

Change-Id: Iea95ea07bb0fed42410efb4e8420d8e9a17704fe
Reviewed-on: https://go-review.googlesource.com/127664
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-21 02:39:52 +00:00
Brad Fitzpatrick
22bb95c5e7 http2/hpack: lazily build huffman table on first use
This generated 120 kB on the heap before at init, regardless of
whether somebody used http2. Worse, because we vendored it into std,
users would have two copies, for about 256 kB of memory. After CL
127235 that went down to 60 kB per copy, so 120 kB for a binary using
golang.org/x/net/http2 explicitly.

With this, it goes to 0 until one of the two copies in the binary
actually uses one of the http2 packages.

I wasn't able to measure any difference with the Once.Do in the decode
path:

name             old time/op    new time/op    delta
HuffmanDecode-4     732ns ± 8%     707ns ± 3%   ~            (p=0.268 n=10+9)

(admittedly noisy)

Change-Id: I6c1065abc0c3458f3cb69e0f678978267ff35ea2
Reviewed-on: https://go-review.googlesource.com/127275
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-01 18:34:31 +00:00
Brad Fitzpatrick
32f9bdbd7d http2/hpack: reduce memory for huffman decoding table
Reduces process-wide heap (inuse_space) by 60kB by using a pointer to
a fixed-sized array instead of a slice of a fixed size.

Before:
119.44kB 23.43% 23.43%   147.88kB 29.01%  golang.org/x/net/http2/hpack.addDecoderNode

After:
 59.72kB 13.28% 39.85%    87.94kB 19.56%  golang.org/x/net/http2/hpack.addDecoderNode

(This is all work from an init func in http2/hpack)

Doesn't seem to affect runtime performance.

Measured with:

$ cat huffman_test.go
package main

import (
        "testing"

        _ "golang.org/x/net/http2"
        )

func TestMem(t *testing.T) {}

$ GODEBUG=memprofilerate=1 go test -memprofilerate=1 -memprofile=mem.prof -v .
=== RUN   TestMem
--- PASS: TestMem (0.00s)
PASS
ok      huffmem 0.052s

$ go tool pprof --inuse_space mem.prof

Change-Id: I5e56a5a2682f1063c955b342b37e97ca4c303dab
Reviewed-on: https://go-review.googlesource.com/127235
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-01 17:40:33 +00:00
Brad Fitzpatrick
49c15d80df http2: revert CL 107295 (don't sniff Content-type in Server when nosniff)
Updates golang/go#24795

Change-Id: Idb018ad9eba1292e91d9339190fdd24ef8a0af4e
Reviewed-on: https://go-review.googlesource.com/126895
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2018-07-31 17:28:58 +00:00
William Chang
c4299a1a0d http2/h2c: add h2c implementation (unencrypted HTTP/2)
Implements h2c by leveraging the existing http2.Server by implementing the 2
ways to start an h2c connection as described in RFC 7540, which are: (1)
create a connection starting with HTTP/1 and then upgrading to h2c [Section 3.2]
and (2) starting a connection directly speaking h2c (aka starting with prior
knowledge) [Section 3.4].

For both of the above connection methods the implementation strategy is to
hijack a HTTP/1 connection, perform the h2c connection on the hijacked
net.Conn, and create a suitably configured net.Conn to pass into
http2.Server.ServeConn.

For h2c with prior knowledge this is relatively simple. For that we just have
to verify the HTTP/2 client preface has been written to the net.Conn, and
then reforward the client preface to the hijacked connection.

For h2c upgraded from HTTP/1, this is a bit more involved. First we validate
the HTTP/1 Upgrade request, and respond to the client with 101 Switching
Protocols. Then we write a HTTP/2 client preface on behalf of the client,
and a settings frame and a headers frame which correspond to what was in
the upgrade request. Then since http2.Server is going respond with a
settings ACK, we swallow it so that it is not forwarded to the client since
for h2c upgrade from HTTP/1 the 101 Switching Protocols response replaces
the settins ACK.

Fixes golang/go#14141

Change-Id: I435f40216c883809c0dcb75426c9c59e2ea31182
Reviewed-on: https://go-review.googlesource.com/112999
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-29 18:37:19 +00:00
Brad Fitzpatrick
3673e40ba2 http2/h2demo: flush headers earlier in demo /ECHO handler
It confused somebody who thought things were hanging because they had
expected to see a response before they started streaming data.

Change-Id: If672956efde3756c966b0c88b9c15ed21daeccba
Reviewed-on: https://go-review.googlesource.com/125644
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-24 23:48:03 +00:00
Brad Fitzpatrick
a680a1efc5 http2: fix typo in comment
Change-Id: If08e7b6133a2458547598cd45ba591ab091cf03f
Reviewed-on: https://go-review.googlesource.com/125035
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-19 18:00:50 +00:00
Brad Fitzpatrick
179114c98f http2: reject large SETTINGS frames or those with duplicates
Per private report.

This isn't actually in the spec, but there's also no need to be so
permissive here.

Change-Id: I2b464778cc502ca7a99ea533622afea8f943eb7d
Reviewed-on: https://go-review.googlesource.com/124735
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-19 17:53:08 +00:00
Brad Fitzpatrick
d0887baf81 http2: fix bug in earlier CL 123615
I both forgot that this list could contain duplicates, and I had
forgot to run the net/http tests against CL 123615 before mailing it,
which ended up catching this bug.

The diff of this file from the commit before CL 123615 (a45b4abe^ ==
cffdcf672) to this commit is:

    https://gist.github.com/bradfitz/0b7abf8fa421515aed9c4d55ce3a1994

... effectively reverting much of CL 123615 and just moving the 1xx
handling down lower.

Updates golang/go#26189 (fixes after vendor into std)
Updates golang/go#17739

Change-Id: Ib63060b0bb9721883b4b91a983b6e117994faeb9
Reviewed-on: https://go-review.googlesource.com/123675
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-12 20:28:26 +00:00
Brad Fitzpatrick
a1d68217f8 http2: export a field of an internal type for use by net/http
Updates golang/go#22891

Change-Id: Ibde5ce0867a78703a5a4f04fafc3d709ea4cbda3
Reviewed-on: https://go-review.googlesource.com/123656
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-12 20:05:04 +00:00
Brad Fitzpatrick
a45b4abe13 http2: ignore unknown 1xx responses like HTTP/1
Updates golang/go#26189 (fixes after vendor into std)
Updates golang/go#17739

Change-Id: I076cdbb57841b7dbbaa764d11240913bc3a8b05d
Reviewed-on: https://go-review.googlesource.com/123615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-12 18:38:42 +00:00
Brad Fitzpatrick
cffdcf672a http2: use GetBody unconditionally on Transport retry, when available
We were previously only using the new-ish Request.GetBody to "rewind"
a Request.Body on retry when it seemed that we hadn't started the
read+write body copy process from the old request yet.

Apparently there's a bug somewhere, so this is a safe minimal fix for
now, unconditionally using GetBody when it's available, rather than
only using it when it seems we need to. Should have no performance impact
because it's supposed to be cheap, and this only happens on rare retries
where the server's GOAWAY came in-flight while we were writing a request.

Updates golang/go#25009 (not a fix, but enough for Go 1.11)

Change-Id: Ia462944d4a68cf2fde8d32b7b357b450c509a349
Reviewed-on: https://go-review.googlesource.com/123476
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-12 04:59:33 +00:00
Michael Fraenkel
039a4258ae http2: a closed stream cannot receive data
Data sent on a closed stream is treated as a connection error of type
STREAM_CLOSED.

Updates golang/go#25023

Change-Id: I3a94414101ec08c7a3f20d49cefc0367af18017f
Reviewed-on: https://go-review.googlesource.com/111676
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-10 23:19:04 +00:00
Michael Fraenkel
d5fb304941 http2: fix race in TestServer_Headers_HalfCloseRemote
Wait until stream is checked before sending data.

Updates golang/go#26314

Change-Id: If8a72d5e9ad313130043d0929dd741486aa2f0cd
Reviewed-on: https://go-review.googlesource.com/123037
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-10 19:07:54 +00:00
Michael Fraenkel
292b43bbf7 http2: reject incoming HEADERS in Server on half-closed streams
Headers received on a half closed remote stream must respond with a
stream error of type STREAM_CLOSED.

Updates golang/go#25023

Change-Id: Ia369b24318aec6df769ecf0911d5152459bb25b2
Reviewed-on: https://go-review.googlesource.com/111677
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-10 02:38:53 +00:00
Brad Fitzpatrick
6a8eb5e2b1 http2: call httptrace.ClientTrace.GetConn in Transport when needed
Tests in CL 122591 in the standard library, to be submitted after this
CL.

Updates golang/go#23041

Change-Id: I3538cc7d2a71e3a26ab4c2f47bb220a25404cddb
Reviewed-on: https://go-review.googlesource.com/122590
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-07-09 22:23:22 +00:00
Olivier Poitrey
b87faa7691 http2: implement client initiated graceful shutdown
Sends a GOAWAY frame and wait for the in-flight streams to complete.

Fixes golang/go#17292

Change-Id: I2b7dd61446f4ffd9c820fbb21d1233c3b3ad1ba8
Reviewed-on: https://go-review.googlesource.com/30076
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-09 22:20:21 +00:00
Brad Fitzpatrick
c4e4b2a67f http2: fire httptrace.ClientTrace.WroteHeaderField if set
ClientTrace.WroteHeaderField was added in Go 1.11.

Updates golang/go#19761 (fixes after vendor into std)

Change-Id: I9a7af31b8601b9cd6efdee63d31a6c05102473d2
Reviewed-on: https://go-review.googlesource.com/122816
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-07-09 21:55:03 +00:00
Brad Fitzpatrick
6f138e0f60 http2: compare Connection header value case-insensitively
The case was ignored elsewhere in this file, but not in this place.

Fixes golang/go#23699

Change-Id: I222092c10aab33d652df5d028cf93716955c20a5
Reviewed-on: https://go-review.googlesource.com/122588
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-09 04:49:23 +00:00
Mikio Hara
4d581e05a3 all: re-adjust build constraints for JS and NaCl
This change fixes the build breakage of h2i on JS and NaCl, and avoids
using unintentional code path on JS.

Change-Id: Ib08f0f6d1d79aecc9bf1e9ee7de52b0a57c22baf
Reviewed-on: https://go-review.googlesource.com/122539
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-07-09 03:26:41 +00:00
Michael Fraenkel
41b796e161 http2: fix expected message order in TestServerHandlerConnectionClose
There is no guaranteed ordering between writing headers and graceful
shutdown, both put a message on different channels.

Fixes golang/go#26190

Change-Id: I883fcf1de4bbe5a87af418d1b897a8aa941f1fd4
Reviewed-on: https://go-review.googlesource.com/122335
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-06 02:05:55 +00:00
Brad Fitzpatrick
97aa3a539e http2: make Server send GOAWAY if Handler sets "Connection: close" header
In Go's HTTP/1.x Server, a "Connection: close" response from a handler results
in the TCP connection being closed.

In HTTP/2, a "Connection" header is illegal and we weren't previously
handling it, generating malformed responses to clients. (This is one
of our violations listed in golang/go#25023)

There was also a feature request in golang/go#20977 for a way for
HTTP/2 handlers to close the connection after the response. Since we
already close the connection for "Connection: close" for HTTP/1.x, do
the same for HTTP/2 and map it to a graceful GOAWAY errcode=NO
response.

Updates golang/go#25023 (improves 8.1.2.2. Connection-Specific Header Fields)
Updates golang/go#20977 (fixes after vendor into std)

Change-Id: Iefb33ea73be616052533080c63b54ae679b1d154
Reviewed-on: https://go-review.googlesource.com/121415
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-28 22:23:18 +00:00
Michael Fraenkel
d1d521f688 http2: correct overflow protection
Correct overflow detection when going negative.

Updates golang/go#25023

Change-Id: Ic2ddb7ee757f081d1826bfbbfd884e2b7e819335
Reviewed-on: https://go-review.googlesource.com/111675
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-28 19:26:13 +00:00