664 Commits

Author SHA1 Message Date
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
Michael Fraenkel
e514e69ffb http2: fix race in flaky TestServer_Rejects_TooSmall
There is a race between scheduling the response of the header frame and
when the data frame error is detected. The header frame may be
queued before or after the stream reset.

Fixes golang/go#25645

Change-Id: Id598eedfec9538fb7b154102a1a6e28e08fe117f
Reviewed-on: https://go-review.googlesource.com/121197
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-27 17:15:09 +00:00
Filippo Valsorda
db08ff08e8 Revert "http2: add X-Content-Type-Options automatically to prevent sniffing"
This reverts commit f73e4c9ed3.

Reason for revert: This turned out to cause more churn and provide less
security than expected.

Updates golang/go#24513

Change-Id: I2c8d0c39f8759ec8895a3261c91a98aeb2303ede
Reviewed-on: https://go-review.googlesource.com/117955
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-11 18:26:52 +00:00
Brad Fitzpatrick
dfa909b99c http2: fix flaky TestTransportHandlerBodyClose
Don't assume goroutines are gone immediately.

Copy the waitCondition & waitErrCondition helpers from net/http's
tests, so we can assume both exist in both repos, even though we only
use one of them as of this CL.

Fixes golang/go#22889

Change-Id: Ife251c9552bc68646e174a7ac082b363e32132a1
Reviewed-on: https://go-review.googlesource.com/114012
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-24 18:17:06 +00:00
Michael Fraenkel
9ef9f5bb98 http2: receiving too much data is a protocol error
Updates golang/go#25023

Change-Id: Icd37dfef1b9558b0e774f1637c5566fb444666d5
Reviewed-on: https://go-review.googlesource.com/111679
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-22 19:04:44 +00:00
Filippo Valsorda
f73e4c9ed3 http2: add X-Content-Type-Options automatically to prevent sniffing
When a Content-Type that triggers content sniffing in old (but still in
significant use) browsers is sent, add the
X-Content-Type-Options: nosniff header, unless explicitly disabled.

Expose httpguts.SniffedContentType for use in the HTTP 1 implementation.

Will be tested by net/http.TestNoSniffHeader_h2.

Updates golang/go#24513

Change-Id: Id1ffea867a496393cb52c5a9f45af97d4b2fcf12
Reviewed-on: https://go-review.googlesource.com/112015
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-09 00:22:18 +00:00
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