1
0
mirror of https://github.com/golang/go synced 2024-10-05 09:21:22 -06:00
Commit Graph

637 Commits

Author SHA1 Message Date
Hiroshi Ioka
e7538df701 net/mail: throw error when multiple addresses are given to ParseAddress
Fixes #14610

Change-Id: I3e57dd60b531c1495ea3bc37ef707a1e4e644baa
Reviewed-on: https://go-review.googlesource.com/20180
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31 10:09:55 +00:00
Brad Fitzpatrick
a6557a05a0 net/http: allow Handlers to handle http2 upgrade PRI requests
The http2 spec defines a magic string which initates an http2 session:

    "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"

It was intentionally chosen to kinda look like an HTTP request, but
just different enough to break things not ready for it. This change
makes Go ready for it.

Notably: Go now accepts the request header (the prefix "PRI *
HTTP/2.0\r\n\r\n") as a valid request, even though it doesn't have a
Host header. But we now mark it as "Connection: close" and teach the
Server to never read a second request from the connection once that's
seen. If the http.Handler wants to deal with the upgrade, it has to
hijack the request, read out the "body", compare it against
"SM\r\n\r\n", and then speak http2. One of the new tests demonstrates
that hijacking.

Fixes #14451
Updates #14141 (h2c)

Change-Id: Ib46142f31c55be7d00c56fa2624ec8a232e00c43
Reviewed-on: https://go-review.googlesource.com/21327
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31 06:12:36 +00:00
Brad Fitzpatrick
0026cb788b net/http: validate transmitted header fields
This makes sure the net/http package never attempts to transmit a
bogus header field key or value and instead fails fast with an error
to the user, rather than relying on the server to maybe return an
error.

It's still possible to use x/net/http2.Transport directly to send
bogus stuff. This change only stops h1 & h2 usage via the net/http
package. A future change will update x/net/http2.

This change also moves some code from request.go to lex.go, which in a
separate future change should be moved so it can be shared with http2
to reduce code bloat.

Updates #14048

Change-Id: I0a44ae1ab357fbfcbe037aa4b5d50669a87f2856
Reviewed-on: https://go-review.googlesource.com/21326
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-31 04:55:58 +00:00
Brad Fitzpatrick
18072adbca net/http: reuse HTTP/1 Transport conns more for gzipped responses
Flip around the composition order of the http.Response.Body's
gzip.Reader vs. the reader which keeps track of waiting to see the end
of the HTTP/1 response framing (whether that's a Content-Length or
HTTP/1.1 chunking).

Previously:

user -> http.Response.Body
     -> bodyEOFSignal
     -> gzipReader
     -> gzip.Reader
     -> bufio.Reader
   [ -> http/1.1 de-chunking reader ]   optional
     -> http1 framing *body

But because bodyEOFSignal was waiting to see an EOF from the
underlying gzip.Reader before reusing the connection, and gzip.Reader
(or more specifically: the flate.Reader) wasn't returning an early
io.EOF with the final chunk, the bodyEOfSignal was never releasing the
connection, because the EOF from the http1 framing was read by a party
who didn't care about it yet: the helper bufio.Reader created to do
byte-at-a-time reading in the flate.Reader.

Flip the read composition around to:

user -> http.Response.Body
     -> gzipReader
     -> gzip.Reader
     -> bufio.Reader
     -> bodyEOFSignal
   [ -> http/1.1 de-chunking reader ]   optional
     -> http1 framing *body

Now when gzip.Reader does its byte-at-a-time reading via the
bufio.Reader, the bufio.Reader will do its big reads against the
bodyEOFSignal reader instead, which will then see the underlying http1
framing EOF, and be able to reuse the connection.

Updates google/go-github#317
Updates #14867
And related abandoned fix to flate.Reader: https://golang.org/cl/21290

Change-Id: I3729dfdffe832ad943b84f4734b0f59b0e834749
Reviewed-on: https://go-review.googlesource.com/21291
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 04:31:13 +00:00
Alex Brainman
9cc22a7f1f net: skip TestInterfacesWithNetsh if "netsh help" contains no English words
Fixes #14859

Change-Id: I262d634ee22498ec9855d273afdd409149765294
Reviewed-on: https://go-review.googlesource.com/21195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-30 01:51:23 +00:00
Brad Fitzpatrick
45d334ecf1 net/http/cgi: allow CGI host to configure where child's stderr goes
Patch originally from Steven Hartland. Tweaked a bit & added a test.

Fixes #7197

Change-Id: I09012b4674e7c641dba31a24e9758cedb898d3ee
Reviewed-on: https://go-review.googlesource.com/21196
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-29 06:57:05 +00:00
Emmanuel Odeke
b9daf0a408 net/http: add more audio/video mime sniffing
Following the spec at
  https://mimesniff.spec.whatwg.org/#matching-an-audio-or-video-type-pattern

Adds signatures for:
+ audio/aiff
+ audio/basic
+ audio/midi
+ audio/mpeg
+ video/avi

Updates the signature for:
+ application/ogg

Also updates the pattern matching algorithm in
  https://mimesniff.spec.whatwg.org/#matching-a-mime-type-pattern
by implementing clause 4 that dictates that the number of bytes in
the pattern must match the number of bytes in the mask.

Fixes #13383

Change-Id: Ie321f392e6570299c17176adf1c75f62f357e1e8
Reviewed-on: https://go-review.googlesource.com/17132
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-26 08:58:57 +00:00
Dominik Honnef
fdba5a7544 all: delete dead non-test code
This change removes a lot of dead code. Some of the code has never been
used, not even when it was first commited. The rest shouldn't have
survived refactors.

This change doesn't remove unused routines helpful for debugging, nor
does it remove code that's used in commented out blocks of code that are
only unused temporarily. Furthermore, unused constants weren't removed
when they were part of a set of constants from specifications.

One noteworthy omission from this CL are about 1000 lines of unused code
in cmd/fix, 700 lines of which are the typechecker, which hasn't been
used ever since the pre-Go 1 fixes have been removed. I wasn't sure if
this code should stick around for future uses of cmd/fix or be culled as
well.

Change-Id: Ib714bc7e487edc11ad23ba1c3222d1fd02e4a549
Reviewed-on: https://go-review.googlesource.com/20926
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-25 06:28:13 +00:00
Brad Fitzpatrick
0104a31b8f vendor: move golang.org/x/net/http2/hpack back to vendor
Updates #14047

Change-Id: I7e314e2c7e3e8da18ab023729740fbc9ea3f661e
Reviewed-on: https://go-review.googlesource.com/21063
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2016-03-24 20:26:51 +00:00
Mohit Agarwal
ddcf8d402a net/http: redirect if the URL path is a dir & doesn't end in a slash
Fixes #13996

Change-Id: I9b2c7fba0705900aca9a70bc6a2687667a9a976c
Reviewed-on: https://go-review.googlesource.com/20128
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-24 02:30:19 +00:00
Brad Fitzpatrick
694eadcce7 net/http/httptest: add NewRequest helper for ease of testing handlers
Fixes #14199

Change-Id: Ic9284023b663de3db1ca7b7b1e96eeab82ec0944
Reviewed-on: https://go-review.googlesource.com/21016
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-23 23:22:22 +00:00
David Crawshaw
d37d3bdcfc net/http, internal/testenv: find go binary in PATH
Fixes #14901

Change-Id: Ia32e09767374a341c9a36c5d977d47d7d1a82315
Reviewed-on: https://go-review.googlesource.com/20967
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2016-03-22 02:02:23 +00:00
Dominik Honnef
b2cf571040 all: delete dead test code
This deletes unused code and helpers from tests.

Change-Id: Ie31d46115f558ceb8da6efbf90c3c204e03b0d7e
Reviewed-on: https://go-review.googlesource.com/20927
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-21 07:10:08 +00:00
Richard Miller
34f0c0b3de net/http: adaptive wait time in PersistConnLeak tests
In tests TransportPersistConnLeak and TransportPersistConnLeakShortBody,
there's a fixed wait time (100ms and 400ms respectively) to allow
goroutines to exit after CloseIdleConnections is called. This
is sometimes too short on a slow host running many simultaneous
tests.

This CL replaces the fixed sleep in each test with a sequence of
shorter sleeps, testing the number of remaining goroutines until
it reaches the threshold or an overall time limit of 500ms expires.
This prevents some failures in the plan9_arm builder, while reducing
the test time on faster machines.

Fixes #14887

Change-Id: Ia5c871062df139e2667cdfb2ce8283e135435318
Reviewed-on: https://go-review.googlesource.com/20922
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-20 22:53:45 +00:00
Marcel van Lohuizen
3e2e80599e net/url: don't assume b.N > 0
Change-Id: Ie79c16d6e61b3baa274069528cf883b22fd255fe
Reviewed-on: https://go-review.googlesource.com/20855
Run-TryBot: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 15:54:59 +00:00
Marcel van Lohuizen
d3ce412fa5 net/rpc: don't assume b.N > 0
Change-Id: I58c4a75168fd1f797a25735c4151f501f0475332
Reviewed-on: https://go-review.googlesource.com/20854
Reviewed-by: Russ Cox <rsc@golang.org>
2016-03-18 15:54:55 +00:00
Mikio Hara
ac2f84d524 net: make unexposed methods start with lowercase letters
This change makes unexposed methods start with lowercase letters for
avoiding unnecessary confusion because the net package uses many
embedding structures and intrefaces for controlling exposure of APIs.

Note that this change leaves DNS-related methods as they are.

Change-Id: I253758d1659175c5d0af6b2efcd30ce83f46543d
Reviewed-on: https://go-review.googlesource.com/20784
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-17 21:43:41 +00:00
Brad Fitzpatrick
8540a1c4df net/http: remove init func reference to ServeMux
Shrinks cmd/go by 30KB.

Change-Id: Ied31192e85af76ebac743f8cc12bd9ef6ec5048f
Reviewed-on: https://go-review.googlesource.com/20765
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-16 21:11:21 +00:00
Brad Fitzpatrick
a96884cf6c net/http: use dynamic type assertion to remove HTTP server code from cmd/go
I was wondering why cmd/go includes the HTTP server implementations.

Dumping the linker's deadcode dependency graph into a file and doing
some graph analysis, I found that the only reason cmd/go included an
HTTP server was because the maxBytesReader type (used by both the HTTP
transport & HTTP server) did a static type assertion to an HTTP server
type.

Changing it to a interface type assertion reduces the size of cmd/go
by 533KB (5.2%)

On linux/amd64, cmd/go goes from 10549200 to 10002624 bytes.

Add a test too so this doesn't regress. The test uses cmd/go as the
binary to test (a binary which needs the HTTP client but not the HTTP
server), but this change and test are equally applicable to any such
program.

Change-Id: I93865f43ec03b06d09241fbd9ea381817c2909c5
Reviewed-on: https://go-review.googlesource.com/20763
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-16 19:43:44 +00:00
Mikio Hara
790053b25e net: filter destination addresses when source address is specified
This change filters out destination addresses by address family when
source address is specified to avoid running Dial operation with wrong
addressing scopes.

Fixes #11837.

Change-Id: I10b7a1fa325add2cd8ed58f105d527700a10d342
Reviewed-on: https://go-review.googlesource.com/20586
Reviewed-by: Paul Marks <pmarks@google.com>
2016-03-16 03:17:56 +00:00
Mikio Hara
76b724cc63 net: prevent spurious TCP connection setup notification on darwin
On the latest darwin kernels, kevent in runtime-integrated network
poller sometimes reports SYN-SENT state sockets as ESTABLISHED ones,
though it's still unclear what's the root cause.

This change prevents such spurious notifications by additional connect
system calls.

Fixes #14548.

Change-Id: Ie29788e38ca735ca77259befeba3229d6a30ac52
Reviewed-on: https://go-review.googlesource.com/20468
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 03:09:28 +00:00
Mikio Hara
5ce0170a26 net: deduplicate Unix socket code
This change consolidates functions and methods related to UnixAddr,
UnixConn and UnixListener for maintenance purpose, especially for
documentation.

The followup changes will update comments and examples.

Updates #10624.

Change-Id: I372d152099ac10956284e6b3863d7e4d9fe5c8e9
Reviewed-on: https://go-review.googlesource.com/20125
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 03:08:31 +00:00
Mikio Hara
028e48c1da net: deduplicate raw IP socket code
This change consolidates functions and methods related to IPAddr and
IPConn for maintenance purpose, especially for documentation.

The followup changes will update comments and examples.

Updates #10624.

Change-Id: Ia5146f234225704a3c0b6459e1903e56a7b68134
Reviewed-on: https://go-review.googlesource.com/20124
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 03:08:13 +00:00
Mikio Hara
20de705b71 net: deduplicate UDP socket code
This change consolidates functions and methods related to UDPAddr and
UDPConn for maintenance purpose, especially for documentation.

The followup changes will update comments and examples.

Updates #10624.

Change-Id: Idfe9be8ea46ade1111b0ae176862b2048eafc7be
Reviewed-on: https://go-review.googlesource.com/20120
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 03:07:52 +00:00
Mikio Hara
1f96c83bf6 net: simplify ipToSockaddr
Change-Id: I5dbcdf0ee0b46b760b2a7decb1d937aac2a6fa8d
Reviewed-on: https://go-review.googlesource.com/20585
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-03-16 03:07:20 +00:00
Dave Day
5630cb7518 net: make SplitHostPort return an empty host on error
This change also refactors SplitHostPort to avoid using gotos and
naked returns.

Fixes #14827

Change-Id: I4dca528936757fd06da76c23af8a0f6175bbedd1
Reviewed-on: https://go-review.googlesource.com/20726
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-15 23:48:53 +00:00
Dominik Honnef
ab5cbc672b net/http: delete unused type readClose
readClose hasn't been used in years.

Change-Id: Ia963c082e049ef856c2a637fec15204efe48b3b6
Reviewed-on: https://go-review.googlesource.com/20631
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-12 22:13:32 +00:00
Emmanuel Odeke
2a7c446f98 net/http: make ParseMultipartForm also populate Request.PostForm
Ensures that after request.ParseMultipartForm has been invoked,
Request.PostForm and Request.Form are both populated with the
same formValues read in, instead of only populating Request.Form.

Fixes #9305

Change-Id: I3d4a11b006fc7dffaa35360014fe15b8c74d00a3
Reviewed-on: https://go-review.googlesource.com/19986
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-12 19:01:47 +00:00
Emmanuel Odeke
637e1aad5c net/http: defer idleMu.Unlock() in tryPutIdleConn + minor typo fixes.
Change-Id: Ia2273c3a9f0001d16b0c767fea91498a9acb0af5
Reviewed-on: https://go-review.googlesource.com/19963
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-11 06:12:28 +00:00
Paul Marks
92dfc12610 net: slowDialTCP should wait forever if no deadline exists.
This allows TestDialerFallbackDelay to pass again on machines where IPv6
connections to nowhere fail quickly instead of hanging.

This bug appeared last month, when I deleted the slowTimeout constant.

Updates #11225
Fixes #14731

Change-Id: I840011eee571aab1041022411541736111c7fad5
Reviewed-on: https://go-review.googlesource.com/20493
Run-TryBot: Paul Marks <pmarks@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-03-10 15:24:44 +00:00
Caio Marcelo de Oliveira Filho
c69e6869c9 net/http/httptest: record trailing headers in ResponseRecorder
Trailers() returns the headers that were set by the handler after the
headers were written "to the wire" (in this case HeaderMap) and that
were also specified in a proper header called "Trailer".

Neither HeaderMap or trailerMap (used for Trailers()) are manipulated by
the handler code, instead a third stagingMap is given to the
handler. This avoid a reference kept by handler to affect the recorded
results.

If a handler just modify the header but doesn't call any Write or Flush
method from ResponseWriter (or Flusher) interface, HeaderMap will not be
updated. In this case, calling Flush in the recorder is enough to get
the HeaderMap filled.

Fixes #14531.
Fixes #8857.

Change-Id: I42842341ec3e95c7b87d7e6f178c65cd03d63cc3
Reviewed-on: https://go-review.googlesource.com/20047
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-08 19:30:38 +00:00
Caio Marcelo de Oliveira Filho
bd68b8abc2 net/http: TimeoutHandler should start timer when serving request
TimeoutHandler was starting the Timer when the handler was created,
instead of when serving a request. It also was sharing it between
multiple requests, which is incorrect, as the requests might start
at different times.

Store the timeout duration and create the Timer when ServeHTTP is
called. Different requests will have different timers.

The testing plumbing was simplified to store the channel used to
control when timeout happens. It overrides the regular timer.

Fixes #14568.

Change-Id: I4bd51a83f412396f208682d3ae5e382db5f8dc81
Reviewed-on: https://go-review.googlesource.com/20046
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-07 23:42:19 +00:00
Mikio Hara
b0f4ee533a net: deduplicate TCP socket code
This change consolidates functions and methods related to TCPAddr,
TCPConn and TCPListener for maintenance purpose, especially for
documentation. Also refactors Dial error code paths.

The followup changes will update comments and examples.

Updates #10624.

Change-Id: I3333ee218ebcd08928f9e2826cd1984d15ea153e
Reviewed-on: https://go-review.googlesource.com/20009
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-03 04:23:59 +00:00
Burcu Dogan
fcb23249b2 net: skip TestLookupPort on android with netgo
/etc/services is not available on Android. The pure Go implementation
of LookupPort will never succeed on Android. Skipping the test.

Updates #14576.

Change-Id: I707ac24aea3f988656b95b1816ee5c9690106985
Reviewed-on: https://go-review.googlesource.com/20154
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-03-03 02:52:18 +00:00
Mohit Agarwal
1c94e7276e net: fix vet warnings
Updates #11041

Change-Id: I12c20beab75d7981efe470eb418e4b58dc8eb066
Reviewed-on: https://go-review.googlesource.com/20002
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 16:26:36 +00:00
Brad Fitzpatrick
3afbb690d5 net/url: fix parsing of URLs ending in question mark
Fixes parsing regression from https://golang.org/cl/19931 which
added the URL.ForceQuery field.

Fixes #14573

Change-Id: I89575cab3f778b1bf78b2389623c866450b26943
Reviewed-on: https://go-review.googlesource.com/20116
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-03-02 03:05:18 +00:00
Brad Fitzpatrick
5fea2ccc77 all: single space after period.
The tree's pretty inconsistent about single space vs double space
after a period in documentation. Make it consistently a single space,
per earlier decisions. This means contributors won't be confused by
misleading precedence.

This CL doesn't use go/doc to parse. It only addresses // comments.
It was generated with:

$ perl -i -npe 's,^(\s*// .+[a-z]\.)  +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.)  +([A-Z])')
$ go test go/doc -update

Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7
Reviewed-on: https://go-review.googlesource.com/20022
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Dave Day <djd@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02 00:13:47 +00:00
Brad Fitzpatrick
519474451a all: make copyright headers consistent with one space after period
This is a subset of https://golang.org/cl/20022 with only the copyright
header lines, so the next CL will be smaller and more reviewable.

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.

Change-Id: Icc26c6b8495c3820da6b171ca96a74701b4a01b0
Reviewed-on: https://go-review.googlesource.com/20111
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-01 23:34:33 +00:00
Brad Fitzpatrick
351c15f1ce all: remove public named return values when useless
Named returned values should only be used on public funcs and methods
when it contributes to the documentation.

Named return values should not be used if they're only saving the
programmer a few lines of code inside the body of the function,
especially if that means there's stutter in the documentation or it
was only there so the programmer could use a naked return
statement. (Naked returns should not be used except in very small
functions)

This change is a manual audit & cleanup of public func signatures.

Signatures were not changed if:

* the func was private (wouldn't be in public godoc)
* the documentation referenced it
* the named return value was an interesting name. (i.e. it wasn't
  simply stutter, repeating the name of the type)

There should be no changes in behavior. (At least: none intended)

Change-Id: I3472ef49619678fe786e5e0994bdf2d9de76d109
Reviewed-on: https://go-review.googlesource.com/20024
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-29 03:31:19 +00:00
Rick Arnold
9f26170a02 net/url: support query string without values
Previously, RawQuery was used to indicate the presence of a query
string in url.URL. However, this approach was not able to differentiate
between URLs that have no query string at all (http://foo.bar/) and
those that have a query with no values (http://foo.bar/?).

Add a ForceQuery field to indicate the latter form of URL and use it
in URL.String to create a matching URL with a trailing '?'.

Fixes #13488

Change-Id: Ifac663c73d35759bc6c33a00f84ab116b9b81684
Reviewed-on: https://go-review.googlesource.com/19931
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26 16:13:26 +00:00
Brad Fitzpatrick
b24c6fbfb3 net/textproto: permit all valid token chars in CanonicalMIMEHeaderKey input
Fixes #13767

Change-Id: Ib743db7d9d72022ea911bc5ac535243489425642
Reviewed-on: https://go-review.googlesource.com/18725
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 21:00:57 +00:00
Emmanuel Odeke
d44088f173 net/http: refactored internal shouldClose for readability
Change-Id: Ie89c0945a4cc3aebfa9f7ad7f107bc7ab59ab61c
Reviewed-on: https://go-review.googlesource.com/19685
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-25 19:11:55 +00:00
Mikio Hara
4accfe1be5 net: re-enable TestDualStack{TCP,UDP}Listener on dragonfly
It looks like the latest DragonFly BSD kernels, at least 4.4 and above,
have finished working on handling of shared IP control blocks. Let's
re-enbale test cases referring to IP control blocks and see what
happens.

Updates #13146.

Change-Id: Icbe2250e788f6a445a648541272c99b598c3013d
Reviewed-on: https://go-review.googlesource.com/19406
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-25 03:14:01 +00:00
Mikio Hara
b48120ca3a net: make TestGoLookupIPWithResolverConfig robust
It crashes when the node under the test is shaken up.

-- FAIL: TestGoLookupIPWithResolverConfig (11.73s)
panic: interface conversion: error is nil, not *net.DNSError [recovered]
	panic: interface conversion: error is nil, not *net.DNSError

goroutine 23 [running]:
panic(0x2e2620, 0xc820181440)
	/go/src/runtime/panic.go:483 +0x3f3
testing.tRunner.func1(0xc820136d80)
	/go/src/testing/testing.go:467 +0x192
panic(0x2e2620, 0xc820181440)
	/go/src/runtime/panic.go:441 +0x4f6
net.TestGoLookupIPWithResolverConfig(0xc820136d80)
	/go/src/net/dnsclient_unix_test.go:358 +0x7ca
testing.tRunner(0xc820136d80, 0x49ddc0)
	/go/src/testing/testing.go:473 +0x98
created by testing.RunTests
	/go/src/testing/testing.go:582 +0x892
exit status 2

Change-Id: I9631f41a3c73f3269c7e30d679c025ae64d71a98
Reviewed-on: https://go-review.googlesource.com/19870
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-25 03:12:59 +00:00
Mikio Hara
7c90abe206 net: fix typo
Change-Id: Ic828256efe0f50a3e11a25d85092d7531b342d2e
Reviewed-on: https://go-review.googlesource.com/19873
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-25 03:11:55 +00:00
Martin Möhrmann
fdd0179bb1 all: fix typos and spelling
Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913
Reviewed-on: https://go-review.googlesource.com/19829
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24 18:42:29 +00:00
Mikio Hara
08f1a778c9 net: rename test files
This change renames {ipraw,tcp,udp,unix}_test.go to
{ipraw,tcp,udp,unix}sock_test.go for clarification. Also moves
NSS-related system configuration test helpers into main_conf_test.go and
main_noconf_test.go.

Change-Id: I28ba1e8ceda7b182ee3aa85f0ca3321388ba45e2
Reviewed-on: https://go-review.googlesource.com/19787
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-02-24 03:07:58 +00:00
Prashant Varanasi
c4cb365ea2 net: fix for DialTimeout errors with large timeout
The existing implementation converts the deadline time to an int64,
but does not handle overflow. If the calculated deadline is negative
but the user specified deadline is in the future, then we can assume
the calculation overflowed, and set the deadline to math.MaxInt64.

Fixes #14431

Change-Id: I54dbb4f02bc7ffb9cae8cf62e4e967e9c6541ec6
Reviewed-on: https://go-review.googlesource.com/19758
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2016-02-23 22:48:04 +00:00
Paul Marks
676550d040 net: use dialTCP cancelation for DualStack dialing.
The previous Happy Eyeballs implementation would intentionally leak
connections, because dialTCP could not be reliably terminated upon
losing the race.

Now that dialTCP supports cancelation (plan9 excluded), dialParallel can
wait for responses from both the primary and fallback racers, strictly
before returning control to the caller.

In dial_test.go, we no longer need Sleep to avoid leaks.
Also, fix a typo in the Benchmark IPv4 address.

Updates #11225
Fixes #14279

Change-Id: Ibf3fe5c7ac2f7a438c1ab2cdb57032beb8bc27b5
Reviewed-on: https://go-review.googlesource.com/19390
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-23 19:26:34 +00:00
Harshavardhana
4ded58bd5a net/http/httputil: Keep response headers when response ContentLength is 0.
Current code does not print any response headers from httputil.DumpResponse().

   PUT /miniocloud/new-file HTTP/1.1
   Host: s3.amazonaws.com
   User-Agent: Go-http-client/1.1
   Content-Length: 11
   Accept-Encoding: gzip

   HTTP/1.1 200 OK

With this fix we get an appropriate output for httputil.DumpResponse().

   PUT /miniocloud/new-file HTTP/1.1
   Host: s3.amazonaws.com
   User-Agent: Go-http-client/1.1
   Content-Length: 11
   Accept-Encoding: gzip

   HTTP/1.1 200 OK
   Content-Length: 0
   Date: Thu, 14 Jan 2016 03:04:42 GMT
   Etag: "3e25960a79dbc69b674cd4ec67a72c62"
   Server: AmazonS3
   X-Amz-Id-2: qnXyH6sknlovV0Myy3emFAXTNtI/sQIcu1ZXNq/6wd17K32tQ7WNGB1qb3nzCpW2DhfeZ/MbWfw=
   X-Amz-Request-Id: 8422EACB0CC492BD

Fixes #13942

Change-Id: Ida063cc3524a96170d8a837893f7c9f49b6cf98e
Reviewed-on: https://go-review.googlesource.com/18624
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-23 15:16:39 +00:00