Граф коммитов

1062 Коммитов

Автор SHA1 Сообщение Дата
Mikio Hara de22433a9f ipv4: add missing IP_HDRINCL option on Windows
Change-Id: Ibb7dacadef404f6fc4e6c744a5015835e580c97e
Reviewed-on: https://go-review.googlesource.com/34094
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-12-07 21:43:41 +00:00
Mikio Hara 9773060888 nettest: update comment on MakePipe
To warn about the provided stop function should not be nil.

Change-Id: I73351b6379ae22e85298ce9e87ee80077f748c7e
Reviewed-on: https://go-review.googlesource.com/34091
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-12-07 01:08:02 +00:00
Mikio Hara 76a3353203 ipv6: add support for linux/{mips,mipsle}
Change-Id: I6f0745cb5754b059dd05fcaf24454936093eaeaa
Reviewed-on: https://go-review.googlesource.com/33934
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-12-06 22:05:56 +00:00
Mikio Hara 188ede5cb6 ipv4: add support for linux/{mips,mipsle}
Change-Id: I13a03838daab0f45a4d9479c3b7baa94021c720a
Reviewed-on: https://go-review.googlesource.com/33933
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-12-06 22:05:33 +00:00
Brad Fitzpatrick 8dab929343 http2: make Transport retry on server's GOAWAY graceful shutdown
Debugged & wrote with Tom Bergan.

Updates golang/go#18083

Change-Id: I00a1cb748fe9c0f01c5bd4b8d1ac4438b56f1f8c
Reviewed-on: https://go-review.googlesource.com/33971
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
2016-12-06 18:33:01 +00:00
Tom Bergan 0c96df335e http2: fix minor stream accounting bug
Update golang/go#18083

Change-Id: I2600f8a7a0d3a630003c010496a7fceca1b9f660
Reviewed-on: https://go-review.googlesource.com/33974
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-06 17:04:49 +00:00
Tom Bergan 4a1c855a05 http2: test for retry after GOAWAY
Updates #golang/go#18083

Change-Id: If0ebbbb9b5644a4cec94c89e28939fcaeb4de321
Reviewed-on: https://go-review.googlesource.com/33972
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-06 00:41:00 +00:00
Joe Tsai 6cdc0daab0 nettest: add package to test for networking conformance
The interface for net.Conn is getting stricter for the Go 1.8 release.
We add a package that tests that a given net.Conn implementation
properly satisfies the interface.

Fixes golang/go#18097

Change-Id: I5e9f1f3c7cb5c060d734ed7e3a24886d4213c4e1
Reviewed-on: https://go-review.googlesource.com/33679
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-02 21:41:19 +00:00
Brad Fitzpatrick 97edce0b2e websocket: mention the gorilla package
Updates golang/go#18152

Change-Id: Ia3df3f9668847690e60a2af0680cf1bd66042384
Reviewed-on: https://go-review.googlesource.com/33806
Reviewed-by: Ross Light <light@google.com>
2016-12-02 00:11:43 +00:00
Mikio Hara 4971afdc2f ipv6: don't fail test on IPv6 disabled kernel
Change-Id: Ib667928f91808640021ea9d61bc5477824729655
Reviewed-on: https://go-review.googlesource.com/33253
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-16 07:50:34 +00:00
Mikio Hara 1fd77278ad ipv6: simplify references to RFCs in package documentation
Change-Id: I8900190d3234d3f8883761b2ae735f2a959b9a26
Reviewed-on: https://go-review.googlesource.com/33252
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-16 07:50:10 +00:00
Mikio Hara 45b0d82e15 ipv6: document that package ipv6 doesn't support Darwin kernel version 12 or below
This change also uses nettest.SupportsIPv6MulticastDeliveryOnLoopback
to disable multicast packet delivery tests on some platform that doesn't
support the feature.

Fixes golang/go#17015.

Change-Id: Ia547efc2ac3779a96592bbc3874533fb65b711af
Reviewed-on: https://go-review.googlesource.com/33251
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-16 07:49:11 +00:00
Mikio Hara 6683f96f09 internal/nettest: make SupportsIPv6 return false on Darwin kernel version 12 or below
The kernel is used in OS X Mountain Lion or below, or iOS version 8 or
below.

Updates golang/go#17015.

Change-Id: I8a849dc2ab4e04535f893b776bf704079cc91977
Reviewed-on: https://go-review.googlesource.com/33250
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-16 07:48:41 +00:00
Mikio Hara 1c5acb2c2d http2: fix a typo
Change-Id: I0c4c58d6488ddf321a5d62b6e9f0dd46f5f40438
Reviewed-on: https://go-review.googlesource.com/33256
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-16 05:35:01 +00:00
Tom Bergan e57319ce2b http2: don't crash when writing RST_STREAM on idle or closed streams
https://go-review.googlesource.com/33238 fixed scheduling of RST_STREAMs so
they are added to the appropriate stream queue. However, RST_STREAM may be
sent before OpenStream or after CloseStream in certain error cases, such as:

00ed5e97ea/http2/server.go (L1395)
00ed5e97ea/http2/frame.go (L866)
00ed5e97ea/http2/frame.go (L947)

In these cases, the failing stream has no queue and in priorityWriteScheduler.Push
will panic. A simple fix is to add RST_STREAMs to the root queue when the stream
queue doesn't exist. This is correct because:

- RST_STREAM is tiny and doesn't use flow control bytes, so prioritization is
  not important.

- The server should not send any frames on a stream after sending RST_STREAM,
  but even if that happens, the RST_STREAM will be ordered before those other
  frames because the control queue has the highest priority.

Fixes golang/go#17919

Change-Id: I2e8101f015822ef975303a1fe87634b36afbdc6b
Reviewed-on: https://go-review.googlesource.com/33248
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-15 22:07:40 +00:00
Tormod Erevik Lea cac22060de trace: remove internal Google reference from comment
Change-Id: I74ca09e4f4765c1c8d309b8fe1ce25b5e3d8171f
Reviewed-on: https://go-review.googlesource.com/33270
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-15 15:07:36 +00:00
Mikio Hara 5bc3a08dc8 webdav: gofmt -w -s
Change-Id: I383c170b38cf2b787c29127efe2d3b0587e6ceec
Reviewed-on: https://go-review.googlesource.com/32138
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-15 03:56:16 +00:00
Brad Fitzpatrick 00ed5e97ea http2: schedule RSTStream writes onto its stream's queue
Fixes golang/go#17243

Change-Id: I76f972f908757b103e2ab8d9b1701312308d66e5
Reviewed-on: https://go-review.googlesource.com/33238
Reviewed-by: Tom Bergan <tombergan@google.com>
2016-11-15 01:38:31 +00:00
Brad Fitzpatrick 0dd7c8d7c3 http2/h2demo: use Let's Encrypt for the TLS cert
The Google-issue one expired and it's too onerous to request another
and do it by hand.

Change-Id: I221406bc66de4b027b979fd87f6ec38f66318f9e
Reviewed-on: https://go-review.googlesource.com/33230
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-14 20:28:35 +00:00
Brad Fitzpatrick 6dfeb344d8 http2: make Server respect http1 Server's SetKeepAlivesEnabled
If the user is using Server.SetKeepAlivesEnabled(false), assume they
have a reason and respect it. Make HTTP/2 behave like HTTP/1 (except a
bit nicer, since we have GOAWAY).

Updates golang/go#17717

Change-Id: I4a5ce324f0ac8653d83e75029063cd2e270a1048
Reviewed-on: https://go-review.googlesource.com/33153
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-14 20:27:36 +00:00
Mikio Hara 8566e9372a Revert "ipv6: disable multicast packet delivery tests on darwin 12 or below"
Looks like using IPv6 options on Darwin 12 kernel is a hard task.

This reverts commit 67a4d4ecbc.

Change-Id: I1436e4ff7b42f068e09671ebe9c244a641eefdae
Reviewed-on: https://go-review.googlesource.com/33173
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-11-14 03:29:31 +00:00
Mikio Hara 67a4d4ecbc ipv6: disable multicast packet delivery tests on darwin 12 or below
Fixes golang/go#17015.

Change-Id: Icfb7a689667e0f1df345d63558f2956596da9fb9
Reviewed-on: https://go-review.googlesource.com/28999
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-11-14 01:08:20 +00:00
Brad Fitzpatrick 0e2717dc3c http2: conditionally log stacks from panics in Server Handlers like net/http
Updates golang/go#17790

Change-Id: I7bc596d9a80490d545ad3d1de5859efce34714f6
Reviewed-on: https://go-review.googlesource.com/33102
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-11-10 23:19:09 +00:00
Brad Fitzpatrick 9ef22118a4 http2: fix CloseNotify data race
Fixes golang/go#17868

Change-Id: I7f9d85f404198d68757d7ca5bb8b1e7aafaafa8b
Reviewed-on: https://go-review.googlesource.com/33013
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-09 21:37:06 +00:00
Tom Bergan 40d3034e57 http2: don't overflow stream IDs in server push
The max allowed stream ID is 2^31-1. The RFC says that we should send
GOAWAY if the ID space is exhausted.

Change-Id: I0042cb4e1f8781a2ece5a5f06f498eb06192da7f
Reviewed-on: https://go-review.googlesource.com/32488
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-08 18:34:30 +00:00
Tom Bergan e36fcd2311 http2: fix racey and flaky server push test
The bad test was added in https://go-review.googlesource.com/32887.
My fault.

Change-Id: Iee98ef0579bc5de086fa286530d45db009407d10
Reviewed-on: https://go-review.googlesource.com/32910
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-08 16:18:42 +00:00
Tom Bergan 87635b2611 http2: disable server push on receiving a GOAWAY
Fixes golang/go#17800

Change-Id: Ibcba9302e2e595ae49d9246ecedd332760486441
Reviewed-on: https://go-review.googlesource.com/32887
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-08 02:21:01 +00:00
Dmitri Shuralyov 5d997795f7 all: make copyright headers consistent with one space after period
Go policy has been single space after periods in comments for some time.

The copyright header template at:

	https://golang.org/doc/contribute.html#copyright

also uses a single space.

Make them all consistent.

This CL was generated with:

	perl -i -npe 's,^(// Copyright [0-9]+ The Go Authors\.)  (All rights reserved\.)$,$1 $2,' $(git grep -l -E '^// Copyright [0-9]+ The Go Authors\.  All rights reserved\.$')

Follows https://golang.org/cl/20111.

Change-Id: I66671dddf821f5dc027bc254e0196b3e3a2bdf3b
Reviewed-on: https://go-review.googlesource.com/32878
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-07 23:52:11 +00:00
Tom Bergan 55a3084c91 http2: fix state tracking for pushed streams
Fix sc.state, which was returning "idle" instead of "closed" if the max
pushed stream ID happened to exceed the max client stream ID. This caused
us to erroneously generate connection errors because we believed a state
invariant had been violated when it had not.

I also renamed maxStreamID to maxClientStreamID for clarity, since we
need to track client-generated and server-generated stream IDs separately.

Fixes golang/go#17777

Change-Id: Id3d5700d79cc699a267bd91d6ebace0770fa62fc
Reviewed-on: https://go-review.googlesource.com/32755
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-04 23:01:06 +00:00
Brad Fitzpatrick 158696dc0d Revert "context: use Go 1.8 type alias for CancelFunc and Context"
This reverts commit dffc95cbb4.

Aliases aren't going into Go 1.8. See:
https://github.com/golang/go/issues/16339#issuecomment-258527920

Updates #16339

Change-Id: Ie37e37349db596a89b4944179ab87b6f0577c826
Reviewed-on: https://go-review.googlesource.com/32753
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-04 20:15:55 +00:00
Brad Fitzpatrick 569280fa63 http2: fix over-aggressive ignoring of frames while in "go away" mode
https://golang.org/cl/31727 made many of the Server Frame processors
ignore incoming frames if the connection was in shutdown mode.

The idea was that it's pointless to do work if we're about to hang up
on them in 250ms anyway for violating a protocol error.

But as of https://golang.org/cl/32412 (graceful shutdown) we can also
be in "go away" mode for ErrCodeNo, which just means to nicely tell
them to GOAWAY and because they did nothing wrong, we don't hang up in
250ms (the value of which gave the peer time to read the error before
the TCP close), but instead we keep the conn open until it's idle.

The combination of the two CLs made TestTransportAndServerSharedBodyRace_h2
flaky, since it was never seeing RST_STREAM on cancelation of requests,
and then Handlers would block forever.

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

Change-Id: I67491c1d7124bc3cb554f9246ea7683f20b6a4e3
Reviewed-on: https://go-review.googlesource.com/32583
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2016-11-03 00:43:54 +00:00
Brad Fitzpatrick 6c4ac8bdbf http2: fix Transport race sending RST_STREAM while reading DATA on cancels
If the client canceled a request, the Transport would then send a
RST_STREAM, but also would close the Response.Body's pipe. Meanwhile,
the server's DATA response could already be on the wire in
flight. We'd then read it, attempt to write its bytes to the buffer,
find it already closed, bubble up that error, and ultimately close the
whole TCP connection (breaking all other open streams).

So, don't do that.

Keep track of which connections we've sent RST_STREAM to, and ignore
DATA frames on those streams.

Updates golang/go#16974 (fixes after bundle to std)

Change-Id: Ic29a3aefff5241146cd2ca80aafa35fc4fb18b6e
Reviewed-on: https://go-review.googlesource.com/32571
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-02 19:42:57 +00:00
Brad Fitzpatrick 3389ddeea9 http2: remove h2-14 ALPN proto
"h2-14" was draft 14 of http2. It's past time to retire announcing it.
Everybody has been using "h2" in the wild for quite some time now.

The Google GFE doesn't accept it anymore either.

Change-Id: I087681a0a5e7117de3ab74a2f3f9e0ae45e007cd
Reviewed-on: https://go-review.googlesource.com/32576
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-02 19:42:17 +00:00
Daniel Theophanes 4bb47a1098 webdav: add Context argument to FileSystem interface
Currently there is no way to pass request scoped information from
the handler to the FileSytem interface. This can be important
to pass credentials or timeout parameters to the FileSystem
operations. Pipe context through the request from
http.Request.Context(). With pre-go1.7 use context.Background().

Custom FileSystem implementations will need to change, but it will
only require a new argument in each of the FileSystem methods.
The change will be trivial to update to.

Fixes golang/go#17658

Change-Id: I7491faf3467ad55db793a68081e074a9b3f9624d
Reviewed-on: https://go-review.googlesource.com/32421
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-11-01 19:16:31 +00:00
Brad Fitzpatrick 541150ac4f http2: make http2.Server access http1's Server via an interface check
The previous way was causing init blocks to be generated which the
linker wasn't smart enough to discard, and the cmd/go tool was once
again including http1 & http2 Servers.

Change-Id: I9d82e14421e0faa96437668f9013d1174f009936
Reviewed-on: https://go-review.googlesource.com/32417
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-31 18:26:26 +00:00
Alex Brainman 4cfeeeb61a http2/h2i: do not assume that stdin value is always 0
Fixes golang/go#17661

Change-Id: Iff004af969c694dde9bc3c56add3a419ab1beac7
Reviewed-on: https://go-review.googlesource.com/32373
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-31 06:31:22 +00:00
Brad Fitzpatrick 73058b0420 http2: add support for graceful shutdown of Server
This adds support for gracefully shutting down the Server, including
sending a GOAWAY frame to clients and shutting down when things are
idle. For now this support is only when integrated with the standard
library's Server.

A future change could export some of this.

Updates golang/go#4674

Change-Id: I78cd4f58ca529bf9d149054f929d9089e7685875
Reviewed-on: https://go-review.googlesource.com/32412
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-10-30 17:52:58 +00:00
Brad Fitzpatrick d6520b84c8 webdav: fix recently-broken tests
The net/http package is now better at HTTP redirects, but that broke
these tests which were trying to test the WebDAV server handler's
behavior for a single roundtrip but were accidentally using the HTTP
client (which does redirects) instead.

Use the http.Transport which only does a single HTTP roundtrip.

Change-Id: I8a0cfe2f841effc2f50c26f90c140e94e256a0ac
Reviewed-on: https://go-review.googlesource.com/32413
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dominik Honnef <dominik@honnef.co>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-30 17:52:45 +00:00
Brad Fitzpatrick 76c1a11e06 http2: change how Server.IdleTimeout is initialized from http.Server
This is an alternate implementation of https://golang.org/cl/32230
which is nicer to the dead code elimination in Go's linker.

The old implementation causes a test in the net/http package to fail:
https://storage.googleapis.com/go-build-log/2c24cf88/linux-amd64_39728ac9.log
... since it caused the cmd/go binary to link in the whole http1 & http2 Server
code, due to the init func and slice which referenced those symbols.

Instead, use an explicit func.

This aso includes the tests meant to be in CL 32230 but which I'd
failed to git add earlier.

Updates golang/go#14204

Change-Id: I13dc138bf0c4df65bc282133ee94036b7f84ab70
Reviewed-on: https://go-review.googlesource.com/32323
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martisch@uos.de>
2016-10-29 23:05:21 +00:00
Brad Fitzpatrick fca93ed71f http2/h2i: update line endings for recent change to console package
The console package empirically seems to require \r\n line endings now,
else the print head does not go back to the left of the screen.

Change-Id: I49f1870b8c48da254afaeaf3daf2e8fdd0432d52
Reviewed-on: https://go-review.googlesource.com/32321
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2016-10-29 20:26:39 +00:00
Nigel Tao 3fe3024eef webdav: have escapeXML perform fewer allocations.
escapeXML was introduced in the previous commit:
https://go-review.googlesource.com/29297

Change-Id: I7d0c982049e495b312b1b8d28ba794444dd605d4
Reviewed-on: https://go-review.googlesource.com/32370
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-29 05:42:29 +00:00
Brad Fitzpatrick dffc95cbb4 context: use Go 1.8 type alias for CancelFunc and Context
CancelFunc was the only part of the context package which didn't
forward nicely with the move from x/net/context to std context.

Use it for Context as well.

Change-Id: Ieff39b10b0783d55d0437c73923053297ed0ea4a
Reviewed-on: https://go-review.googlesource.com/32317
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2016-10-28 22:21:43 +00:00
Brad Fitzpatrick b336a971b7 http2: initialize Server.IdleTimeout from http.Server as http1 does
This makes ConfigureServer initialize the http2 Server's IdleTimeout
from the http1 Server configuration, using the same rules as
IdleTimeout in Go 1.8: first use IdleTimeout if specified, else fall
back to the old ReadTimeout.

Updates golang/go#14204

Change-Id: I4dee971f8416ef0cbf99335a199c46355f9ab09d
Reviewed-on: https://go-review.googlesource.com/32230
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-27 20:31:54 +00:00
Brad Fitzpatrick b626cca987 http2: fix optimized write scheduling
Fixes regression from https://golang.org/cl/31495 which generated
massive stacks like:

net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859bc70, 0x18c26050, 0x1897c1c0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3664 +0x34a
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859bb50, 0x18c26060, 0x0, 0x0, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3742 +0xc8
net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859bb50, 0x18c26060, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3689 +0x23f
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).writeFrame(0x1890e7e0, 0x859bb50, 0x18c26060, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3648 +0x6b
net/http.(*http2serverConn).resetStream(0x1890e7e0, 0x1, 0x8, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3815 +0x91
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859b6d0, 0x1890db00, 0x1897c1c0, 0x18ede040, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3736 +0x124
net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859b6d0, 0x1890db00, 0x1897c1c0, 0x18ede040)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3689 +0x23f
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859bc70, 0x18c26018, 0x0, 0x0, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3742 +0xc8
net/http.(*http2serverConn).startFrameWrite(0x1890e7e0, 0x859bc70, 0x18c26018, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3689 +0x23f
net/http.(*http2serverConn).scheduleFrameWrite(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3779 +0x114
net/http.(*http2serverConn).wroteFrame(0x1890e7e0, 0x859b730, 0x18ede000, 0x1897c1c0, 0x0, 0x0, 0x0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3742 +0xc8
net/http.(*http2serverConn).serve(0x1890e7e0)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3504 +0x50d
net/http.(*http2Server).ServeConn(0x18ab49a0, 0x859e040, 0x18df2000, 0x1894ae18)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3152 +0x6d9
net/http.http2ConfigureServer.func1(0x18d364e0, 0x18df2000, 0x859a1b0, 0x18ab2308)
    /tmp/workdir/go/src/net/http/h2_bundle.go:3033 +0x70
net/http.(*conn).serve(0x18ad60f0, 0x859cbc0, 0x18aa42a0)
    /tmp/workdir/go/src/net/http/server.go:1633 +0xf03

This changes it to be a loop instead.

This also fixes the "internal error: attempt to send frame on
half-closed-local stream" crash from golang/go#17627 because
wroteFrame set stateHalfClosedLocal temporarily while calling
resetStream which itself does a write in some cases. Prior to CL 31495
those writes were processed breadth-first. CL 31495 made the writes
generated from resetStream (like the window updates returning unused
flow-control) more aggressive and scheduled immediately. This loop
restores the old write scheduling.

Fixes golang/go#17627

Change-Id: I9651568e4105791d24d46819499efc7e018c86c3
Reviewed-on: https://go-review.googlesource.com/32217
Reviewed-by: Tom Bergan <tombergan@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-27 17:37:18 +00:00
Tom Bergan c46f265c32 http2: implement support for server push
This makes x/net/http2's ResponseWriter implement the new interface,
http.Pusher. This new interface requires Go 1.8. When compiled against
older versions of Go, the ResponseWriter does not have a Push method.

Fixes golang/go#13443

Change-Id: I8486ffe4bb5562a94270ace21e90e8c9a4653da0
Reviewed-on: https://go-review.googlesource.com/29439
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-27 00:19:06 +00:00
Tom Bergan 65dfc08770 http2: reject stream self-dependencies
Fix spec bug: Section 5.3.1 says that self-dependencies should be
treated as a stream error of type PROTOCOL_ERROR.

Updates golang/go#16046

Change-Id: I8b5dc8808943dc96aac0c543c7032fa989ab9e0b
Reviewed-on: https://go-review.googlesource.com/31858
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-24 23:31:26 +00:00
Brad Fitzpatrick e7b14352cc http2: optimize server frame writes
Don't do async frame writes when the write is known to be small enough
to definitely fit in the write buffer and not cause a flush (which
might block). This avoids starting a new goroutine and doing a channel
send operation for many frame writes.

name                  old time/op    new time/op    delta
ServerGets-4             146µs ± 2%     144µs ± 1%  -1.46%        (p=0.000 n=14+14)
ServerPosts-4            162µs ± 1%     160µs ± 1%  -1.15%        (p=0.000 n=15+15)
Server_GetRequest-4      145µs ± 1%     143µs ± 0%  -1.26%        (p=0.000 n=15+15)
Server_PostRequest-4     160µs ± 1%     158µs ± 1%  -1.32%        (p=0.000 n=15+15)

The headers frame is the main last one which might show some benefit
if there's a cheap enough way to conservatively calculate its size.

Change-Id: I9be2ddbf04689340819d8701ea671fff378d9e79
Reviewed-on: https://go-review.googlesource.com/31495
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-24 18:47:39 +00:00
Tom Bergan 4be9b97e3a http2: interface to support pluggable schedulers
This adds an interface to support pluggable schedulers. The interface
is defined in writesched.go. The only type needed by this interface is
FrameWriteRequest, which describes a request to write a frame (this used
to be called frameWriteMsg). The scheduler can be configured with a new
field in http2.Server. Two schedulers are implemented:

1) A random scheduler that is essentially equivalent to the existing
   scheduler. This is currently the default scheduler if none is
   configured. The implementation is in writesched_random.go.

2) A scheduler that uses H2 weights and priorities. The H2 priority tree
   is maintained as a tree of priorityNodes. The next frame is chosen by
   walking this tree in topological order, where sibling nodes are ordered
   by their bandwidth usage relative to their H2 weight. Two optional
   features are added to improve performance -- these are configured with
   PriorityWriteSchedulerConfig.

Fixes golang/go#16168

Change-Id: I97ec93e5c58c2efec35455ba2f3c31e849f706af
Reviewed-on: https://go-review.googlesource.com/25366
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-10-24 17:05:25 +00:00
Nigel Tao 5695785b44 publicsuffix: update table to latest list from publicsuffix.org
Update the list to revision 915565885d0fbd25caf7d8b339cd3478f558da94
(2016-10-19T08:16:09Z).

Change-Id: Ie94e7237015f2d84e0a0d082bd7ff9e04b05ecd9
Reviewed-on: https://go-review.googlesource.com/31530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-24 07:02:33 +00:00
Brad Fitzpatrick c33d37840d http2: add Server.IdleTimeout
Also remove some stale TODOs and finish one of the TODOs, ignoring
more incoming frames when the connection is in GOAWAY mode.

Also, fix independently-broken transport test from a change in std:
https://golang.org/cl/31595

Updates golang/go#14204

Change-Id: Iae8b02248464d613979c30d8f86eacb329cd262f
Reviewed-on: https://go-review.googlesource.com/31727
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-23 13:31:18 +00:00