Commit Graph

760 Commits

Author SHA1 Message Date
Brad Fitzpatrick
d62542d18c http2: client conn pool abstraction
Change-Id: Icbf40b26a25c7084efd062a0a66385450ec537aa
Reviewed-on: https://go-review.googlesource.com/16699
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-11-07 15:33:02 +00:00
Brad Fitzpatrick
633434aadc http2: add Transport.RoundTripOpt, adds option to RoundTrip without new dials
For integration with the net/http.Transport.

Updates golang/go#6891

Change-Id: I7a44e4c4259aa57cec1b54666c333b5fc519caf8
Reviewed-on: https://go-review.googlesource.com/16692
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-11-07 13:07:18 +00:00
Volker Dobler
b4e17d61b1 publicsuffix: update table to latest list from publicsuffix.org.
Change-Id: I4e4eb9c710b0ee21a2ade97fd7d38cbd984a6b7f
Reviewed-on: https://go-review.googlesource.com/16424
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-11-02 10:32:43 +00:00
Brad Fitzpatrick
c95266fa70 http2: fix Server race with ResponseWriter.curWrite re-use
Kill off that field and simplify the code. Also update some docs.

Thanks to Totoro W for the diagnosis in https://golang.org/cl/16465

Sadly this race was never detected due to golang/go#13097

Fixes golang/go#13089

Change-Id: Ia5400ea6733c7824e872affc3c6720bd436911fe
Reviewed-on: https://go-review.googlesource.com/16490
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-30 00:49:25 +00:00
Brad Fitzpatrick
2fd7f1556c http2: another Transport body-writing bug fix, and more tests
Change-Id: I700832c477a38ab11da39a382186bdc7d3d3186e
Reviewed-on: https://go-review.googlesource.com/16445
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-29 17:54:54 +00:00
Brad Fitzpatrick
24ab552e98 http2: fix Transport's flow control control when writing request bodies
Adapation of Blake's proposed fix in https://golang.org/cl/16463
with a few changes:

-- bug fix (advance the buffer after writing)
-- don't reacquire/release the buffer in the loop. it was done like
   that in case the max frame size changed while writing. Instead, push
   that down into awaitFlowControl since it has to acquire that lock
   anyway. Now it returns between 1 and the lower of how much we read
   and how much we're allowed to write.

This does mean that if we start a request with a max frame size of
32KB, we'll never write larger than 32KB frames until the the next
request (because our scratch buffer we read into is only 32KB), but we
will start writing smaller DATA frames immediately once we see the
peer's SETTINGS frame.

Change-Id: I47fc503062f9602fe448cf7a36fc500e5d6b8ef9
Reviewed-on: https://go-review.googlesource.com/16443
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-29 17:11:37 +00:00
Blake Mizerany
1b27761f1c http2: swallow io.EOF while reading body and flow fix
This commit fixes two bugs.

The first bug returned io.EOF when a zero bytes were read from the
request body.

The second bug was a hang where the Transport waited for more flow
tokens than initialWindowSize BEFORE sending the first data frame which
never gave the server a chance to send flow tokens, so the client never
got enough to unblock awaitFlowControl. This commit changes
awaitFlowControl to wait for for [1,max] tokens, where max is the length
of the scratch buffer.

Change-Id: Ibbac0a38cd672535917a38330998d3b48d46f5f1
Reviewed-on: https://go-review.googlesource.com/16411
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-28 23:57:56 +00:00
Blake Mizerany
ce84af2e5b http2: append query to :path pseudo-header
Change-Id: Id10c0a9a5652bc38d6ae324f160b41af95bbee7f
Reviewed-on: https://go-review.googlesource.com/16412
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-28 21:18:19 +00:00
Blake Mizerany
e1a5816c9b http2: add DialTLS to Transport
This commit allows a client of Transport to supply their own Dial
function that assumes all TLS checks have been performed and the
returned net.Conn is an h2 ready client connection.

Change-Id: If35b5c47c3bd6912a990d6cd89feefa3303bb42b
Reviewed-on: https://go-review.googlesource.com/16289
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-27 22:14:21 +00:00
Brad Fitzpatrick
efe38d9b30 http2: push stream look up later in Transport, address some TODOs/cleanups
Change-Id: Iaed80981b985e6e02ede5afc4a224490c4ceac01
Reviewed-on: https://go-review.googlesource.com/16380
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-27 21:43:27 +00:00
Brad Fitzpatrick
0a9f6507bc http2: prevent deadlock channel send in server Handler if client disappears
Noticed during a crash in earlier testing. This now matches all the
other channel sends, selecting on the serverConn's terminiation channel.

Change-Id: I27ad3f9fd2d61154a5b95da82735d34fc2cbbc0b
Reviewed-on: https://go-review.googlesource.com/16381
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-27 21:41:21 +00:00
Brad Fitzpatrick
a7d8d4e9cf http2: send WINDOW_UPDATE frames while reading Transport Response bodies
Change-Id: I3cbdf6107dfe13a0fb57d677059ca2106b1afb25
Reviewed-on: https://go-review.googlesource.com/16334
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-27 19:43:20 +00:00
Brad Fitzpatrick
6281f06c8c http2: add per-Response buffered response bodies with separate flow control
Change-Id: I795d230b78b43aea4c2088b1d04c927b2418a7a3
Reviewed-on: https://go-review.googlesource.com/16333
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-27 19:43:14 +00:00
Brad Fitzpatrick
09d2a416fa http2: write Transport bodies
Some polish and testing remains, but this should be the bulk of the
Transport work that was remaining.

There's one notable (but easy) TODO about sending WINDOW_UPDATE frames
every few hundred MB or so, but this is a checkpoint.

Updates golang/go#6891

Change-Id: Iced9850804bf2c069c75118895ee7c3750ba31b5
Reviewed-on: https://go-review.googlesource.com/16310
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-27 19:26:11 +00:00
Brad Fitzpatrick
b7f5d985f9 http2: change the pipe and buffer code
Make the pipe code take an interface as the backing store.  Now a pipe
is something that's goroutine-safe and does the Cond waits but its underlying data
is now an interface: anything that's a ReaderWriter with a Len method (such as a
*bytes.Buffer), or a fixedBuffer (renamed in this CL from 'buffer').

This opens the ground to having a non-fixed buffer used with pipe.

This also moves the CloseWithError code up into the pipe code, out of
fixedBuffer.

Change-Id: Ia3b853e8aa8920807b705ff4e41bed934a8c67b7
Reviewed-on: https://go-review.googlesource.com/16312
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-10-27 18:48:40 +00:00
Brad Fitzpatrick
2cba614e8f http2: remove Transport.Fallback
We decided to glue together the HTTP/1 and HTTP/2 Transports in the
other direction, having the HTTP/1 code (net/http.Transport) start the
flow.

Remove the http2 Transport.Fallback for now, rather than leaving it
half implemented.

For background, see https://golang.org/cl/16090

Updates golang/go#6891

Change-Id: I511bc6d35a1a9a8e20010bd95ff694a894f42aa4
Reviewed-on: https://go-review.googlesource.com/16181
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-22 14:09:15 +00:00
Brad Fitzpatrick
e71042db1c http2: add Transport.AddIdleConn
This adds the http2 Transport method needed by
https://golang.org/cl/16090 to glue the HTTP/1 Transport
(net/http.Transport) to the http2.Transport without throwing away
fresh TCP connections after the TLS handshake determines which
NPN/ALPN protocol was selected.

Updates golang/go#6891

Change-Id: Iba004c8b1a149a5ee6c755d9a3fc1b19856a4e47
Reviewed-on: https://go-review.googlesource.com/16180
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-22 14:09:12 +00:00
Brad Fitzpatrick
9946ad7d5e http2: quiet Transport logging
Add logf/vlogf helpers for Transport like the server side.

Change-Id: I9c9e5dc38c06118204da615c59de60cd3f9561ef
Reviewed-on: https://go-review.googlesource.com/16064
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-20 23:06:47 +00:00
Brad Fitzpatrick
564010564f http2: fix server race
This changes makes sure we never write to *writeData in the ServeHTTP
goroutine until the serve goroutine is done with it.

Also, it makes sure we don't transition the stream to the closed state
on the final DATA frame concurrently with the write.

To fix both, the writeFrameAsync goroutine no longer replies directly back
to the ServeHTTP goroutine with the write result. It's now passed to
the serve goroutine instead, which looks at the frameWriteMsg to
decide how to advance the state machine, then signals the ServeHTTP
goroutine with the result, and then advances the state machine.

Because advancing the state machine could transition it to closed,
which the ServeHTTP goroutine might also be selecting on, make the
ServeHTTP goroutine prefer its frameWriteMsg response channel for errors
over the stream closure in its select.

Various code simplifications and robustness in the process.

Tests now pass reliably even with high -count values, -race on/off,
etc. I've been unable to make h2load be unhappy now either.

Thanks to Tatsuhiro Tsujikawa (Github user @tatsuhiro-t) for the bug
report and debugging clues.

Fixes golang/go#12998

Change-Id: I441c4c9ca928eaba89fd4728d213019606edd899
Reviewed-on: https://go-review.googlesource.com/16063
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-20 23:04:06 +00:00
Brad Fitzpatrick
c972803da8 http2: update the curl and nghttp2 versions used in tests
Also add a new h2load test, disabled by default.

Change-Id: I0fcfdbf38cf86481c6347dd7e0a1daed7d9c7b65
Reviewed-on: https://go-review.googlesource.com/16062
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-20 22:43:35 +00:00
Brad Fitzpatrick
ddbc69e05b http2: fix broken test after ConfigureServer change
ConfigureServer now returns an error if your config is wrong. It
doesn't attempt to fix it for you. Adjust this test accordingly.

Change-Id: Ie3de878ff58cef454de0ec9ab1a10459ca0ddd2d
Reviewed-on: https://go-review.googlesource.com/16061
Reviewed-by: Adam Langley <agl@golang.org>
2015-10-20 16:49:56 +00:00
Brad Fitzpatrick
42ad50856d http2: make ConfigureServer set PreferServerCipherSuites, return an errors
Fixes golang/go#12895

Change-Id: I7cf6e63b1bbdf1f4e8974c00bdaed69b74f6db49
Reviewed-on: https://go-review.googlesource.com/15860
Reviewed-by: Adam Langley <agl@golang.org>
2015-10-19 19:27:35 +00:00
Sameer Ajmani
96feaeba77 context: attempt to deflake TestLayersTimeout with timer padding.
Fixes #11512.

Change-Id: Iaf98ec25fb16a2409c1ff7d110afa6477267d3e1
Reviewed-on: https://go-review.googlesource.com/13643
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-19 16:59:31 +00:00
Brad Fitzpatrick
cd8c2701a5 http2: add support for net/http.Server.ConnState tracking
This is required to work with the upcoming rewrite of the
httptest.Server's connection tracking in
https://go-review.googlesource.com/#/c/15151/
which (at least as of patchset 7) doesn't forcefully tear
down a StateNew connection during Server.Wait. That might
change.

In any case, this adds support for ConnState, which users would
expect regardless of protocol in a mixed HTTP/1 and HTTP/2
environment.

Change-Id: I124aafec29dda123a018935fa306f465ae99cd97
Reviewed-on: https://go-review.googlesource.com/15913
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-16 00:54:17 +00:00
Brad Fitzpatrick
21c3935a8f http2/hpack: push down max string length checking further, improve docs
Change-Id: I875835875f8f97158f2dc88e508a075929af931e
Reviewed-on: https://go-review.googlesource.com/15827
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-14 20:37:54 +00:00
Brad Fitzpatrick
52798024a3 http2/h2demo: allow alternate hostnames for http and https links
Fixes golang/go#12905

Change-Id: I73b3041f06ca93ad0e75251ca32f077fa9eafe8d
Reviewed-on: https://go-review.googlesource.com/15826
Reviewed-by: Arnout Engelen <arnout@bzzt.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-14 19:41:52 +00:00
Andrew Gerrand
6d10a0c3ea http2: update copyright headers
Change-Id: I043b392053bdf61ef863dfcb083ff6034d9322e7
Reviewed-on: https://go-review.googlesource.com/15840
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-14 04:32:53 +00:00
Brad Fitzpatrick
59e870b296 http2, http2/hpack: add limit on sum of header block fragments
Fixes golang/go#12916

Change-Id: I085ebc1d3f851d7c1b689a715c4f2fe85be4608a
Reviewed-on: https://go-review.googlesource.com/15821
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-14 01:29:49 +00:00
Brad Fitzpatrick
c94bffa210 http2: don't leaving hanging server goroutines after RST_STREAM from client
In general, clean up and simplify the handling of frame writing from
handler goroutines.  Always select on streams closing, and don't try
to pass around and re-use channels. It was too confusing. Instead,
reuse channels in a very local manner that's easy to reason about.

Thanks to Github user @pabbott0 (who has signed the Google CLA) for
the initial bug report and test cases.

Fixes bradfitz/http2#45

Change-Id: Ib72a87cb6e33a4bb118ae23d765ba594e9182ade
Reviewed-on: https://go-review.googlesource.com/15820
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-14 01:27:35 +00:00
Brad Fitzpatrick
271cfc1e29 http2: fix handling of errors from the readFrames goroutine
There was a design problem earlier where the serve goroutine assumed
that the readFrame goroutine could return only connection-level
errors, but the readFrames goroutine (and the underlying Framer)
assumed it could return stream-level errors (type StreamError) and
have them handled as stream errors in the layers above. That's how it
should have been, and what this CL does.

Now readFrames returns both the Frame and error from ReadFrames
together as a pair, and an error isn't necessarily fatal to the
connection.

Fixes golang/go#12733
Fixes bradfitz/http2#53

Change-Id: If4406ceaa019886893d3c61e6bfce25ef74560d3
Reviewed-on: https://go-review.googlesource.com/15735
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-10-13 15:21:57 +00:00
Brad Fitzpatrick
442fc736aa http2/hpack: fix nil pointer dereference crash in huffman decoder
Return an error instead.

Fixes bradfitz/http2#56

Change-Id: I3d1e80a214a8635932479943f0ef9610ee02b233
Reviewed-on: https://go-review.googlesource.com/15738
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-13 14:13:00 +00:00
Brad Fitzpatrick
d8f3c68ddd http2: fix enforcement of max header list size
In the first attempt to enforce the SETTINGS_MAX_HEADER_LIST_SIZE
(https://go-review.googlesource.com/15751), the enforcement happened
in the hpack decoder and the hpack decoder returned errors on Write
and Close if the limit was violated. This was incorrect because the
decoder is used over the life of the connection and all subsequent
requests and could therefore get out of sync.

Instead, this moves the counting of the limit up to the http2 package
in the serverConn type, and replaces the hpack counting mechanism with
a simple on/off switch. When SetEmitEnabled is set false, the header
field emit callbacks will be suppressed and the hpack Decoder will do
less work (less CPU and garbage) if possible, but will still return
nil from Write and Close on valid input, and will still stay in sync
it the stream.

The http2 Server then returns a 431 error if emits were disabled while
processing the HEADER or any CONTINUATION frames.

Fixes golang/go#12843

Change-Id: I3b41aaefc6c6ee6218225f8dc62bba6ae5fe8f2d
Reviewed-on: https://go-review.googlesource.com/15733
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-13 00:37:42 +00:00
Brad Fitzpatrick
2a045c20e4 http2: change two debug log.Printf calls to vlogf
Fixes golang/go#12742

Change-Id: I04d65b0c68ccb5da5ee90650c7b0593fbdb1d470
Reviewed-on: https://go-review.googlesource.com/15736
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-13 00:02:17 +00:00
Brad Fitzpatrick
4b709d9377 http2/hpack: make staticTable an array, not a slice
Minor performance improvement, since len(staticTable) is then a
constant at compile time.

Change-Id: Ie51ecc985aa3f40d50f0a7d1ab6ac91738f696d5
Reviewed-on: https://go-review.googlesource.com/15731
Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-12 00:47:14 +00:00
Brad Fitzpatrick
29704b8f8f http2: advertise and enforce hpack max header list size
Thanks to Andy Bursavich for the example attack.
Pair programmed with Dmitri Shuralyov.

Fixes golang/go#12843

Change-Id: Ic412c9364b37a10e5164232aa809b956874fae08
Reviewed-on: https://go-review.googlesource.com/15751
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-11 02:56:28 +00:00
Brad Fitzpatrick
b846920a17 http2: move where cookies are joined to avoid quadratic behavior
There are already tests which cover the behavior. This is simply
moving where it happens. I'm not adding new tests to cover the very
bad behavior because once the rest of the bug is fixed, it won't be
possible to observe anyway. But even for smallish inputs, this is
faster.

Part of golang/go#12843

Change-Id: I7d69f2409e2adb4a01d101a915e09cf887b03f21
Reviewed-on: https://go-review.googlesource.com/15601
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-08 14:50:43 +00:00
Burcu Dogan
47990a1ba5 readme: use golang.org links rather than github.com
Change-Id: I2b0b87aed4ff5c338b0ae09b63f55411322a871e
Reviewed-on: https://go-review.googlesource.com/15436
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-06 05:09:49 +00:00
David Symonds
01256db42e http2/h2demo: Update some links left dangling after the bradfitz/http2 -> x/net/http2 move.
Change-Id: Idd45c1be493f4535d73323fc2feda5efff45763e
Reviewed-on: https://go-review.googlesource.com/15243
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-02 03:19:12 +00:00
Mikio Hara
ac0ecaccab icmp: drop unnecessary type assertions in PacketConn
Change-Id: I8bd9d181c4c2e8c4ea01342a306acdca69eabf18
Reviewed-on: https://go-review.googlesource.com/15085
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-02 01:10:14 +00:00
Mikio Hara
d14987874b ipv6: don't use internal/iana's constants in documentation
Change-Id: I8f41ef0d3eefecb26d073e21bc1d5b7b6a51d259
Reviewed-on: https://go-review.googlesource.com/15053
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-02 01:08:56 +00:00
Arnout Engelen
c2528b2dd8 http2/h2demo: show load times on gophertimes demo page
Change-Id: I3d3905adab74a83c9d7d72c829f6686b514f3aaf
Reviewed-on: https://go-review.googlesource.com/15060
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-27 18:28:33 +00:00
Tamir Duberstein
7c302550d1 http2: use net.JoinHostPort
This makes it correct for IPv6 too.

Change-Id: Ide2fc12ed97974b6abbafa66c4b83d0086c4e87c
Reviewed-on: https://go-review.googlesource.com/15030
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-27 06:22:57 +00:00
Mikio Hara
dc692bc613 ipv4: don't use internal/iana's constants in documentation
Change-Id: I55d6ad683b8021722fec8b42b2a8aa0a1883cb96
Reviewed-on: https://go-review.googlesource.com/15052
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-27 05:26:17 +00:00
Brad Fitzpatrick
03affa02f1 http2: delete now-redundant top-level files, update README
Change-Id: I95471bf40cf5b0ceb2dfc01d4c831acb65265719
Reviewed-on: https://go-review.googlesource.com/14950
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
2015-09-24 12:55:35 +00:00
Brad Fitzpatrick
b19c071601 http2: merge github.com/bradfitz/http2 (branch: golang.org/x/net)
This adds the http2 directory from github.com/bradfitz/http2

(Merge reviewed by David Symonds <dsymonds@golang.org>)
2015-09-24 09:57:49 +02:00
Brad Fitzpatrick
ae54c55587 http2: rewrite github.com/bradfitz/http2 references to their new paths 2015-09-24 09:24:43 +02:00
Brad Fitzpatrick
17e723d022 http2: move github.com/bradfitz/http2 down into a new http2 directory
In prep for move to golang.org/x/net/*.
2015-09-24 09:24:40 +02:00
Federico Simoncelli
db8e4de5b2 webdav: improve support for url prefixes
StripPrefix in the webdav package strips prefixes from requests
(including the Destination headers) but cannot handle the paths
in the xml entities responses which are confusing some clients
(e.g. cadaver).

This patch replaces StripPrefix with Prefix in the Handler to
handle prefixes both in the requests and in the xml entities
responses.

Change-Id: I67062e30337b2ae422c82a2f927454f5a8a00e34
Reviewed-on: https://go-review.googlesource.com/13857
Reviewed-by: Nigel Tao <nigeltao@golang.org>
2015-09-03 01:41:53 +00:00
Michael Gehring
ea47fc708e trace: fix EventLog example
Fixes golang/go#12387

Change-Id: Iecc42d9f809bed10036d1c3af8838c2fbf7ea93d
Reviewed-on: https://go-review.googlesource.com/14014
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-08-29 23:03:18 +00:00
David Symonds
7654728e38 trace: Export Render and RenderEvents functions.
These expose the main HTML rendering functions of this package
for use with alternate HTTP muxes and on alternate paths.

Fixes golang/go#12195.

Change-Id: I679583fd26116bc83ff551a5d2a1d73ffa1e01f0
Reviewed-on: https://go-review.googlesource.com/13825
Reviewed-by: Dave Day <djd@golang.org>
2015-08-24 03:25:21 +00:00