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

644 Commits

Author SHA1 Message Date
Brad Fitzpatrick
a699320512 net/http: update docs on Request.Proto, ProtoMajor, ProtoMinor
Change-Id: I4a6928b4674b6aaab3611cad7526347923a0015f
Reviewed-on: https://go-review.googlesource.com/18153
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-29 18:54:39 +00:00
Russ Cox
04d732b4c2 build: shorten a few packages with long tests
Takes 3% off my all.bash run time.

For #10571.

Change-Id: I8f00f523d6919e87182d35722a669b0b96b8218b
Reviewed-on: https://go-review.googlesource.com/18087
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-29 15:46:44 +00:00
Jonathan Boulle
5b5e19ea65 net/http: fix typo in docstring
s/activitiy/activity

Change-Id: Ib2bbc929b38b1993000da57daed2d795f4a93997
Reviewed-on: https://go-review.googlesource.com/18131
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-24 01:28:11 +00:00
Mikio Hara
11ac72a116 net: fix race in TestTCPStress
Fixes #13704.

Change-Id: I7afef5058fa88b0de41213cf46219b684369f47f
Reviewed-on: https://go-review.googlesource.com/18111
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-22 03:39:39 +00:00
Mikio Hara
f80f6e4580 net/internal/socktest: simplify log message format
This change replaces the existing log format separated by commas and
spaces with space-separated one.

Change-Id: I9a4b38669025430190c9a1a6b5c82b862866559d
Reviewed-on: https://go-review.googlesource.com/17999
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-22 03:38:51 +00:00
David Symonds
8567fb7a0a net/http: add new HTTP 451 status code, Unavailable For Legal Reasons.
Approved by the IETF.

https://datatracker.ietf.org/doc/draft-ietf-httpbis-legally-restricted-status/

Change-Id: I688597bb5f7ef7c7a9be660a4fcd2ef02d9dc9f4
Reviewed-on: https://go-review.googlesource.com/18112
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Symonds <dsymonds@golang.org>
2015-12-22 02:14:22 +00:00
Mikio Hara
97f854cd7b net: make use of IPv4 for parsing routing information on windows
In general the package net deals IPv4 addresses as IPv6 IPv4-mapped
addresses internally for the dual stack era, when we need to support
various techniques on IPv4/IPv6 translation.

This change makes windows implementation follow the same pattern which
BSD variants and Linux do.

Updates #13544.

Also fixes an unintentionally formatted line by accident by gofmt.

Change-Id: I4953796e751fd8050c73094468a0d7b0d33f5516
Reviewed-on: https://go-review.googlesource.com/17992
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-19 10:00:04 +00:00
Alex Brainman
2cf5f04ffd net: adjust TestInterfaceHardwareAddrWithGetmac
CL skips interfaces that are not listed on getmac output.

Fixes #13606

Change-Id: Ic25c9dc95e8eeff4d84b78e99131a4f97020164c
Reviewed-on: https://go-review.googlesource.com/17994
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
2015-12-19 09:05:38 +00:00
Brad Fitzpatrick
b73e247a8e net/http: document that Server.TLSNextProto has automatic HTTP/2 also
Copy the same sentence from Transport.TLSNextProto.

Change-Id: Ib67bf054e891a68be8ba466a8c52968363374d16
Reviewed-on: https://go-review.googlesource.com/18031
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-18 18:30:39 +00:00
Brad Fitzpatrick
c70df74aab net/http: document ResponseWriter and Handler more; add test
Update docs on ResponseWriter and Handler around concurrency.

Also add a test.

The Handler docs were old and used "object" a lot. It was also too
ServeMux-centric.

Fixes #13050
Updates #13659 (new issue found in http2 while writing the test)

Change-Id: I25f53d5fa54f1c9d579d3d0f191bf3d94b1a251b
Reviewed-on: https://go-review.googlesource.com/17982
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 21:21:31 +00:00
Brad Fitzpatrick
c052222b34 net/http: don't accept invalid bytes in server request headers
Fixes #11207

Change-Id: I7f00b638e749fbc7907dc1597347ea426367d13e
Reviewed-on: https://go-review.googlesource.com/17980
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 20:22:08 +00:00
Brad Fitzpatrick
18227bb7b6 net/http: be more consistent about Request.Method "" vs "GET"
Patch from Russ.

No bug identified, but I didn't search exhaustively. The new code is
easier to read.

Fixes #13621

Change-Id: Ifda936e4101116fa254ead950b5fe06adb14e977
Reviewed-on: https://go-review.googlesource.com/17981
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 20:21:44 +00:00
Brad Fitzpatrick
66fcf56729 net/http: update bundled http2, add tests reading response Body after Close
Updates to golang.org/x/net/http2 git rev 28273ec9 for
https://golang.org/cl/17937

Fixes #13648

Change-Id: I27c77524b2e4a172c5f8be08f6fbb0f2e2e4b200
Reviewed-on: https://go-review.googlesource.com/17938
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 19:49:13 +00:00
Brad Fitzpatrick
807c6c58fc net: fix the build even harder
Should fix nacl.

Follow-up to
https://golang.org/cl/17936 (fix race) and
https://golang.org/cl/17914 (fix build) for
https://golang.org/cl/16953 (broke the build)

Third time's a charm.

Change-Id: I23930d5cff4235209546952ce2231f165ab5bf8a
Reviewed-on: https://go-review.googlesource.com/17939
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-17 18:43:12 +00:00
Brad Fitzpatrick
cfc9fde54d net/http: updated bundled http2 to finish trailer support
This updates the bundled copy of x/net/http2 to git rev d2ecd08
for https://golang.org/cl/17912 (http2: send client trailers)
and enables the final Trailer test for http2.

Fixes #13557

Change-Id: Iaa15552b82bf7a2cb01b7787a2e1ec5ee680a9d3
Reviewed-on: https://go-review.googlesource.com/17935
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 17:50:30 +00:00
Alex Brainman
f172a28f24 net: include both ipv4 and ipv6 netsh output in TestInterfacesWithNetsh
Also include test for interface state (up or down).

Updates #13606

Change-Id: I03538d65525ddd9c2d0254761861c2df7fc5bd5a
Reviewed-on: https://go-review.googlesource.com/17850
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-17 17:41:41 +00:00
Brad Fitzpatrick
3ad3d5931b net: fix race in test
Fixes race builders, broken in https://golang.org/cl/16953

Change-Id: Id61171672b69d0ca412de4b44bf2c598fe557906
Reviewed-on: https://go-review.googlesource.com/17936
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 17:26:30 +00:00
Russ Cox
aaa0bc1043 net/http: document a few ServeMux behaviors
Fixes #13639.
Fixes #11757.

Change-Id: Iecf9ebcd652c23c96477305a41082e5b63b41d83
Reviewed-on: https://go-review.googlesource.com/17955
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 17:03:05 +00:00
Brad Fitzpatrick
8cdd7d14ac net: fix build
https://golang.org/cl/16953 broke the world.

Change-Id: I7cbd4105338ff896bd0c8f69a0b126b6272be2e5
Reviewed-on: https://go-review.googlesource.com/17914
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-17 16:06:58 +00:00
Brad Fitzpatrick
53a207131d net/http: document that ListenAndServe is a bit more than Listen+Serve
Document that ListenAndServe and ListenAndServeTLS also set TCP
keep-alives.

Fixes #12748

Change-Id: Iba2e8a58dd657eba326db49a6c872e2d972883a4
Reviewed-on: https://go-review.googlesource.com/17681
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 15:54:24 +00:00
Dan Peterson
5c0629b503 net: prefer error for original name on lookups
With certain names and search domain configurations the
returned error would be one encountered while querying a
generated name instead of the original name. This caused
confusion when a manual check of the same name produced
different results.

Now prefer errors encountered for the original name.

Also makes the low-level DNS connection plumbing swappable
in tests enabling tighter control over responses without
relying on the network.

Fixes #12712
Updates #13295

Change-Id: I780d628a762006bb11899caf20b5f97b462a717f
Reviewed-on: https://go-review.googlesource.com/16953
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 15:17:06 +00:00
Brad Fitzpatrick
64de502caa net/http: update Response.Trailer doc
I updated this in the previous commit (https://golang.org/cl/17931)
but noticed a typo. and it still wasn't great.

The Go 1.5 text was too brief to know how to use it:

    // Trailer maps trailer keys to values, in the same
    // format as the header.

Change-Id: I33c49b6a4a7a3596735a4cc7865ad625809da900
Reviewed-on: https://go-review.googlesource.com/17932
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-17 02:46:04 +00:00
Brad Fitzpatrick
691e63b7fe net/http: update bundled copy of http2, enable TestTrailersServerToClient tests
This CL updates the bundled copy of x/net/http2 to include
https://golang.org/cl/17930 and enables the previously-skipped tests
TestTrailersServerToClient_h2 and TestTrailersServerToClient_Flush_h2.

It also updates the docs on http.Response.Trailer to describe how to
use it. No change in rules. Just documenting the old unwritten rules.
(there were tests locking in the behavior, and misc docs and examples
scattered about, but not on http.Response.Trailer itself)

Updates #13557

Change-Id: I6261d439f6c0d17654a1a7928790e8ffed16df6c
Reviewed-on: https://go-review.googlesource.com/17931
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
2015-12-17 01:29:43 +00:00
Alex Brainman
f33f9b2cee net: make windows (*netFD).connect work like its unix version
CL 17821 used syscall.CancelIoEx to cancel outstanding connect
call, but did not check for syscall.CancelIoEx return value.
Also I am worried about introducing race here. We should use
proper tools available for us instead. For example, we could
use fd.setWriteDeadline just like unix version does. Do that.

Change-Id: Idb9a03c8c249278ce3e2a4c49cc32445d4c7b065
Reviewed-on: https://go-review.googlesource.com/17920
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
2015-12-16 23:51:38 +00:00
Brad Fitzpatrick
e8e786c20d net/http: updated bundled copy of x/net/http2
Updates to x/net/http2 git rev c24de9d5

Change-Id: I3d929ae38dca1a93e9a262d4eaaafee1d36fa839
Reviewed-on: https://go-review.googlesource.com/17896
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 21:00:35 +00:00
Brad Fitzpatrick
654daac3bc net/http: split Trailers tests into two halves
The old test was in client_test.go but was a mix of four things:

- clients writing trailers
- servers reading trailers
- servers writing trailers
- clients reading trailers

It definitely wasn't just about clients.

This moves it into clientserver_test.go and separates it into two
halves:

- servers writing trailers + clients reading trailers
- clients writing trailers + servers reading trailers

Which still isn't ideal, but is much better, and easier to read.

Updates #13557

Change-Id: I8c3e58a1f974c1b10bb11ef9b588cfa0f73ff5d9
Reviewed-on: https://go-review.googlesource.com/17895
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-16 20:25:46 +00:00
Brad Fitzpatrick
6e11f45ebd net/http: make Server validate Host headers
Fixes #11206 (that we accept invalid bytes)
Fixes #13624 (that we don't require a Host header in HTTP/1.1 per spec)

Change-Id: I4138281d513998789163237e83bb893aeda43336
Reviewed-on: https://go-review.googlesource.com/17892
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-16 19:52:07 +00:00
Brad Fitzpatrick
c2fb457ef7 net/url: fix RFC typo in comments
Change-Id: I04ed7e5ab992c1eb3528432797026d0c7d2818f1
Reviewed-on: https://go-review.googlesource.com/17894
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-16 19:19:36 +00:00
Brad Fitzpatrick
1fe3933920 net/http: fix Transport race returning bodyless responses and reusing conns
The Transport had a delicate protocol between its readLoop goroutine
and the goroutine calling RoundTrip. The basic concern is that the
caller's RoundTrip goroutine wants to wait for either a
connection-level error (the conn dying) or the response. But sometimes
both happen: there's a valid response (without a body), but the conn
is also going away. Both goroutines' logic dealing with this had grown
large and complicated with hard-to-follow comments over the years.

Simplify and document. Pull some bits into functions and do all
bodyless stuff in one place (it's special enough), rather than having
a bunch of conditionals scattered everywhere. One test is no longer
even applicable since the race it tested is no longer possible (the
code doesn't exist).

The bug that this fixes is that when the Transport reads a bodyless
response from a server, it was returning that response before
returning the persistent connection to the idle pool. As a result,
~1/1000 of serial requests would end up creating a new connection
rather than re-using the just-used connection due to goroutine
scheduling chance. Instead, this now adds bodyless responses'
connections back to the idle pool first, then sends the response to
the RoundTrip goroutine, but making sure that the RoundTrip goroutine
is outside of its select on the connection dying.

There's a new buffered channel involved now, which is a minor
complication, but it's much more self-contained and well-documented
than the previous complexity. (The alternative of making the
responseAndError channel itself unbuffered is too invasive and risky
at this point; it would require a number of changes to avoid
deadlocked goroutines in error cases)

In any case, flakes look to be gone now. We'll see if trybots agree.

Fixes #13633

Change-Id: I95a22942b2aa334ae7c87331fddd751d4cdfdffc
Reviewed-on: https://go-review.googlesource.com/17890
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 17:50:32 +00:00
Mikio Hara
1dc2e7b165 net: retighten test harnesses for dial cancelation
Updates #11225.

Change-Id: I6c33d577f144643781f370ba2ab0997d1c1a3820
Reviewed-on: https://go-review.googlesource.com/17880
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-16 01:05:47 +00:00
Brad Fitzpatrick
24a83d3545 net: add Dialer.Cancel to cancel pending dials
Dialer.Cancel is a new optional <-chan struct{} channel whose closure
indicates that the dial should be canceled. It is compatible with the
x/net/context and http.Request.Cancel types.

Tested by hand with:

package main

    import (
            "log"
            "net"
            "time"
    )

    func main() {
            log.Printf("start.")
            var d net.Dialer
            cancel := make(chan struct{})
            time.AfterFunc(2*time.Second, func() {
                    log.Printf("timeout firing")
                    close(cancel)
            })
            d.Cancel = cancel
            c, err := d.Dial("tcp", "192.168.0.1:22")
            if err != nil {
                    log.Print(err)
                    return
            }
            log.Fatalf("unexpected connect: %v", c)
    }

Which says:

    2015/12/14 22:24:58 start.
    2015/12/14 22:25:00 timeout firing
    2015/12/14 22:25:00 dial tcp 192.168.0.1:22: operation was canceled

Fixes #11225

Change-Id: I2ef39e3a540e29fe6bfec03ab7a629a6b187fcb3
Reviewed-on: https://go-review.googlesource.com/17821
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-15 21:15:15 +00:00
Brad Fitzpatrick
479c47e478 net/http: maybe deflake TestCancelRequestMidBody_h2 on linux-noopt builder
This might deflake it. Or it'll at least give us more debugging clues.

Fixes #13626 maybe

Change-Id: Ie8cd0375d60dad033ec6a64830a90e7b9152a3d9
Reviewed-on: https://go-review.googlesource.com/17825
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-15 21:07:46 +00:00
Brad Fitzpatrick
99fb19194c net/http: rework CloseNotifier implementation, clarify expectations in docs
CloseNotifier wasn't well specified previously. This CL simplifies its
implementation, clarifies the public documentation on CloseNotifier,
clarifies internal documentation on conn, and fixes two CloseNotifier
bugs in the process.

The main change, though, is tightening the rules and expectations for using
CloseNotifier:

* the caller must consume the Request.Body first (old rule, unwritten)
* the received value is the "true" value (old rule, unwritten)
* no promises for channel sends after Handler returns (old rule, unwritten)
* a subsequent pipelined request fires the CloseNotifier (new behavior;
  previously it never fired and thus effectively deadlocked as in #13165)
* advise that it should only be used without HTTP/1.1 pipelining (use HTTP/2
  or non-idempotent browsers). Not that browsers actually use pipelining.

The main implementation change is that each Handler now gets its own
CloseNotifier channel value, rather than sharing one between the whole
conn. This means Handlers can't affect subsequent requests. This is
how HTTP/2's Server works too. The old docs never clarified a behavior
either way. The other side effect of each request getting its own
CloseNotifier channel is that one handler can't "poison" the
underlying conn preventing subsequent requests on the same connection
from using CloseNotifier (this is #9763).

In the old implementation, once any request on a connection used
ClosedNotifier, the conn's underlying bufio.Reader source was switched
from the TCPConn to the read side of the pipe being fed by a
never-ending copy. Since it was impossible to abort that never-ending
copy, we could never get back to a fresh state where it was possible
to return the underlying TCPConn to callers of Hijack. Now, instead of
a never-ending Copy, the background goroutine doing a Read from the
TCPConn (or *tls.Conn) only reads a single byte. That single byte
can be in the request body, a socket timeout error, io.EOF error, or
the first byte of the second body. In any case, the new *connReader
type stitches sync and async reads together like an io.MultiReader. To
clarify the flow of Read data and combat the complexity of too many
wrapper Reader types, the *connReader absorbs the io.LimitReader
previously used for bounding request header reads.  The
liveSwitchReader type is removed. (an unused switchWriter type is also
removed)

Many fields on *conn are also documented more fully.

Fixes #9763 (CloseNotify + Hijack together)
Fixes #13165 (deadlock with CloseNotify + pipelined requests)

Change-Id: I40abc0a1992d05b294d627d1838c33cbccb9dd65
Reviewed-on: https://go-review.googlesource.com/17750
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-15 21:01:53 +00:00
Brad Fitzpatrick
d4df6f4874 net/http: updated bundled http2 copy, enable some tests
Updates bundled copy of x/net/http2 to include
https://golang.org/cl/17823 (catching panics in Handlers)

Fixes #13555

Change-Id: I08e4e38e736a8d93f5ec200e8041c143fc6eafce
Reviewed-on: https://go-review.googlesource.com/17824
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-15 05:05:00 +00:00
Brad Fitzpatrick
9b1068ad2f net/http/httputil: make DumpRequest use Request.RequestURI when available
Fixes #10912

Change-Id: If04e3205d5cc43ebfd6864bc59340c8697cbc0af
Reviewed-on: https://go-review.googlesource.com/17592
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-15 04:48:33 +00:00
Burcu Dogan
4280ed84fd net/http: skip TestClientTimeout_Headers in HTTP/2 mode
Change-Id: I3533b557cd6c7127ab4efbe8766184b51ce260c9
Reviewed-on: https://go-review.googlesource.com/17768
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-15 01:46:34 +00:00
Burcu Dogan
9025408ab5 net/http: test client timeout against HTTP/2
Change-Id: Id511855da1c663250a4ffb149277a3f4a7f38360
Reviewed-on: https://go-review.googlesource.com/17766
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-15 00:43:53 +00:00
Brad Fitzpatrick
e568a0180a net/http: add Transport tests for using Request.Cancel mid-body
This CL also updates the bundled http2 package with the h2 fix from
https://golang.org/cl/17757

Fixes #13159

Change-Id: If0e3b4bd04d0dceed67d1b416ed838c9f1961576
Reviewed-on: https://go-review.googlesource.com/17758
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-14 23:01:20 +00:00
Brad Fitzpatrick
5a88e54fda net: make LookupPort with empty service mean 0
Fixes #13610

Change-Id: I9c8f924dc1ad515a9697291e981ece34fdbec8b7
Reviewed-on: https://go-review.googlesource.com/17755
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-14 20:41:36 +00:00
Russ Cox
2190750ce1 net: add test for CL 17458
I thought that we avoided creating on-disk Unix sockets,
but I was mistaken. Use one to test CL 17458.

Fixes #11826.

Change-Id: Iaa1fb007b95fa6be48200586522a6d4789ecd346
Reviewed-on: https://go-review.googlesource.com/17725
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-14 20:37:42 +00:00
Brad Fitzpatrick
0954c80114 net/http: update bundled http2 copy from x/net/http2
Updates to x/net git rev 6c105c0a

Fixes #13598

Change-Id: I207d4c78d744f0fd83cb5acd8bd6e5987e59a4f7
Reviewed-on: https://go-review.googlesource.com/17756
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-14 18:50:27 +00:00
Brad Fitzpatrick
0478f7b9d6 net/http: fix race in TimeoutHandler
New implementation of TimeoutHandler: buffer everything to memory.

All or nothing: either the handler finishes completely within the
timeout (in which case the wrapper writes it all), or it misses the
timeout and none of it gets written, in which case handler wrapper can
reliably print the error response without fear that some of the
wrapped Handler's code already wrote to the output.

Now the goroutine running the wrapped Handler has its own write buffer
and Header copy.

Document the limitations.

Fixes #9162

Change-Id: Ia058c1d62cefd11843e7a2fc1ae1609d75de2441
Reviewed-on: https://go-review.googlesource.com/17752
Reviewed-by: David Symonds <dsymonds@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-14 14:55:37 +00:00
Mikio Hara
24a7955c74 net: fix typo
Change-Id: I064a7e21bdc55d7f72147bcf6cfb91b96dbb77bb
Reviewed-on: https://go-review.googlesource.com/17795
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-14 08:26:42 +00:00
Mikio Hara
6a1c2a5989 net: add missing File{Conn,Listener,PacketConn} read/write tests
At present, the series of File{Conn,Listener,PacketConn} APIs are the
only way to configure platform-specific socket options such as
SO_REUSE{ADDR,PORT}, TCP_FASTOPEN. This change adds missing test cases
that test read and write operations on connections created by File APIs
and removes redundant parameter tests which are already tested in
server_test.go.

Also adds comment on full stack test cases for IPConn.

Fixes #10730.

Change-Id: I67abb083781b602e876f72a6775a593c0f363c38
Reviewed-on: https://go-review.googlesource.com/17476
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-14 03:14:53 +00:00
Emmanuel Odeke
a028892882 net/http: annotate equivalent h2 tests for h1
Change-Id: Ic639443d4a8536dd54c5b0cf5a9b6d1474448f77
Reviewed-on: https://go-review.googlesource.com/17593
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-14 01:11:29 +00:00
Russ Cox
617c93ce74 net/url: reject space in host; do not escape < > " in host
Host names in URLs must not use %-escaping for ASCII bytes, per RFC 3986.

url.Parse has historically allowed spaces and < > " in the URL host.
In Go 1.5, URL's String method started escaping those,
but then Parse would rejects the escaped form.
This CL is an attempt at some consistency between Parse and String
as far as the accepted host characters and the encoding of host characters,
so that if Parse succeeds, then Parse -> String -> Parse also succeeds.

Allowing space seems like a mistake, so reject that in Parse.
(Similarly, reject \t, \x01, and so on, all of which were being allowed.)

Allowing < > " doesn't seem awful, so continue to do that,
and go back to the Go 1.4 behavior of not escaping them in String.

Fixes #11302.

Change-Id: I0bf65b874cd936598f20694574364352a5abbe5f
Reviewed-on: https://go-review.googlesource.com/17387
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-11 05:17:38 +00:00
Russ Cox
a4fd325c17 net: do not unlink unix socket in UnixListener created from fd
Fixes #11826.

Change-Id: Id220dd558ca8d8d78c01975087122d27757deea0
Reviewed-on: https://go-review.googlesource.com/17458
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-11 04:43:44 +00:00
Russ Cox
503cbcef70 net/url: add tests for RequestURI returning //paths
Fixes #10433.

Change-Id: I2a8b54e3f07488f204b1d14eb2603842caaf1e5a
Reviewed-on: https://go-review.googlesource.com/17386
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-10 20:03:03 +00:00
Brad Fitzpatrick
9ccdc4edac net/http/httptest: don't crash in mime sniffing if HeaderMap is nil
Fixes some failing Google tests when run under Go tip (1.6).

Updates #12986

Change-Id: I0ca4d20f6103d10ea9464e45730085401336dada
Reviewed-on: https://go-review.googlesource.com/17698
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Nodir Turakulov <nodir@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-10 18:51:54 +00:00
Brad Fitzpatrick
8233ecd1b2 net/http: make NewRequest with empty method mean GET
Until recently, we always permitted an empty string to NewRequest.
Keep that property, since it broke tests within in Google when trying
out Go 1.6, and probably would've broken others too.

Change-Id: Idddab1ae7b9423d5caac00af2c897fe1065b600b
Reviewed-on: https://go-review.googlesource.com/17699
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-10 18:51:50 +00:00
Mikio Hara
e05b48e22c net, internal/syscall/windows: fix interface and address identification on windows
The current implementation including Go 1.5 through 1.5.2 misuses
Windows API and mishandles the returned values from GetAdapterAddresses
on Windows. This change fixes various issues related to network facility
information by readjusting interface and interface address parsers.

Updates #5395.
Updates #10530.
Updates #12301.
Updates #12551.
Updates #13542.
Fixes #12691.
Fixes #12811.
Fixes #13476.
Fixes #13544.

Also fixes fragile screen scraping test cases in net_windows_test.go.

Additional information for reviewers:

It seems like almost all the issues above have the same root cause and
it is misunderstanding of Windows API. If my interpretation of the
information on MSDN is correctly, current implementation contains the
following bugs:

- SIO_GET_INTERFACE_LIST should not be used for IPv6. The behavior of
  SIO_GET_INTERFACE_LIST is different on kernels and probably it doesn't
  work correctly for IPv6 on old kernels such as Windows XP w/ SP2.
  Unfortunately MSDN doesn't describe the detail of
  SIO_GET_INTERFACE_LIST, but information on the net suggests so.

- Fetching IP_ADAPTER_ADDRESSES structures with fixed size area may not
  work when using IPv6. IPv6 generates ton of interface addresses for
  various addressing scopes. We need to adjust the area appropriately.

- PhysicalAddress field of IP_ADAPTER_ADDRESSES structure may have extra
  space. We cannot ignore PhysicalAddressLength field of
  IP_ADAPTER_ADDRESS structure.

- Flags field of IP_ADAPTER_ADDRESSES structure doesn't represent any of
  administratively and operatinal statuses. It just represents settings
  for windows network adapter.

- MTU field of IP_ADAPTER_ADDRESSES structure may have a uint32(-1) on
  64-bit platform. We need to convert the value to interger
  appropriately.

- IfType field of IP_ADAPTER_ADDRESSES structure is not a bit field.
  Bitwire operation for the field is completely wrong.

- OperStatus field of IP_ADAPTER_ADDRESSES structure is not a bit field.
  Bitwire operation for the field is completely wrong.

- IPv6IfIndex field of IP_ADAPTER_ADDRESSES structure is just a
  substitute for IfIndex field. We cannot prefer IPv6IfIndex to IfIndex.

- Windows XP, 2003 server and below don't set OnLinkPrefixLength field
  of IP_ADAPTER_UNICAST_ADDRESS structure. We cannot rely on the field
  on old kernels. We can use FirstPrefix field of IP_ADAPTER_ADDRESSES
  structure and IP_ADAPTER_PREFIX structure instead.

- Length field of IP_ADAPTER_{UNICAST,ANYCAST,MULTICAST}_ADDRESS
  sturecures doesn't represent an address prefix length. It just
  represents a socket address length.

Change-Id: Icabdaf7bd1d41360a981d2dad0b830b02b584528
Reviewed-on: https://go-review.googlesource.com/17412
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-10 08:04:07 +00:00
Brad Fitzpatrick
c2ef005486 net/http: run more tests in http2 mode
Failing ones are marked skipped.

Fixes #13543 (was just a test issue)
Updates #13555 (to be fixed later)
Updates #13556 (to be fixed later)
Updates #13557 (to be fixed later)
Fixes bug in golang.org/cl/17428 (http1 now uses HTTP status 431, not 413)

Change-Id: I8f7431fee35f2fc081cfe2c232ae75a00800a60b
Reviewed-on: https://go-review.googlesource.com/17683
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-10 04:43:08 +00:00
Brad Fitzpatrick
efc806e92e net/http: clarify some RoundTripper behaviors
Fixes #12796
Updates #13444

Change-Id: I56840c0baf9b32a683086a80f5db1c5ea0a7aedf
Reviewed-on: https://go-review.googlesource.com/17680
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-09 17:35:43 +00:00
Emmanuel Odeke
b8b65c10e0 net/http: make testCaseSensitiveMethod also test http2
Change-Id: I6427b0914fc4ccd9b841eae3aefe3b7a355fc436
Reviewed-on: https://go-review.googlesource.com/17596
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 14:56:13 +00:00
Alex Brainman
9a89ac35fe net: add TestInterfaceHardwareAddrWithGetmac
Use Windows getmac command to verify interface
MAC addresses net package returns.

The test is to be enabled once issue #12691 is fixed.

Updates #12691

Change-Id: Ic28c83303590cb4d48ee025250d4b6e30683bfd4
Reviewed-on: https://go-review.googlesource.com/17632
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 06:48:26 +00:00
Alex Brainman
1b7a2273e5 net: add TestInterfaceAddrsWithNetsh
Use windows netsh command to verify interface
addresses and netmasks net package returns.

The test is to be enabled once issue #12811
is fixed.

Updates #12811

Change-Id: I191e350a1403e5133791d4ec59561fefa24f5c61
Reviewed-on: https://go-review.googlesource.com/17478
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09 04:41:16 +00:00
Emmanuel Odeke
560937434d net/http: testClientHead now in http2 mode
Change-Id: I21317e3f60502759efc026cdfdb0b1d5f411cae9
Reviewed-on: https://go-review.googlesource.com/17521
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 01:10:10 +00:00
Emmanuel Odeke
b220d41666 net/http: sniffTest for 5953 set in http2 mode
Change-Id: I345b6ea7024a1c85c805b2d2e22f9f79aeca5816
Reviewed-on: https://go-review.googlesource.com/17462
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 01:00:44 +00:00
Emmanuel Odeke
5d7dc23ec5 net/http: clientHeadContentLength test now in http2 mode
Change-Id: If6cc1298ad550790ee981c1b5dc618a14947dc4a
Reviewed-on: https://go-review.googlesource.com/17526
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 01:00:35 +00:00
Emmanuel Odeke
cdc65778a2 net/http: testClientRedirectEatsBody test now in http2 mode
Change-Id: I181346a8d2a8a96fd790cde087c8fd73af911298
Reviewed-on: https://go-review.googlesource.com/17529
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 00:24:26 +00:00
Brad Fitzpatrick
3d3d6eb79d net/http: update bundled http2 and add tests for two fixed issues
Updates to http2's golang.org/cl/17590 (git rev 1796f9b8b)

Fixes #13495
Fixes #13532

Change-Id: I9b95ab438e1d895c75d031d8fcf2605921182a5e
Reviewed-on: https://go-review.googlesource.com/17591
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 00:22:09 +00:00
Emmanuel Odeke
1092257f7e net/http: zeroLengthPostAndResponse test now in http2 mode
Change-Id: I282a399657c71f7b6406fcdde8afc82a13bdfe5f
Reviewed-on: https://go-review.googlesource.com/17530
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-09 00:13:30 +00:00
Emmanuel Odeke
10d1d5b673 net/http: testStreamingGet now in http2 mode
Change-Id: I9a1fe057f5bf008fa16577a7d71064050aea47e9
Reviewed-on: https://go-review.googlesource.com/17525
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-08 22:23:06 +00:00
Brad Fitzpatrick
9b8080f37e net/http: update bundled http2 copy
Updates golang.org/x/net/http2 to git rev 438097d76

Fixes #13444

Change-Id: I699ac02d23b56db3e8a27d3f599ae56cd0a5b4b2
Reviewed-on: https://go-review.googlesource.com/17570
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-08 22:01:01 +00:00
Emmanuel Odeke
3d70475833 net/http: sniffWrite test also in http2 mode
Change-Id: Ifa9f1ed6a3b8d3f7536f2d315259940335b0ee49
Reviewed-on: https://go-review.googlesource.com/17438
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-07 15:50:34 +00:00
Russ Cox
a6869d1c5c net/url: accept non-ASCII bytes in URL per RFC 3986
Fixes #7991.
Fixes #12719.

Change-Id: I5650fa35ec5d49addeda6cc6e7fa93cfbe1cdfc0
Reviewed-on: https://go-review.googlesource.com/17385
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-07 14:01:56 +00:00
Yuval Pavel Zholkover
4a2915052b Revert "syscall: route_freebsd switch routing socket sysctl to use NET_RT_IFLISTL"
This reverts commit f25f6eab0c.

Sorry, this was not meant to go in without the ztypes_freebsd_arm.go and the copyFromV9 function.

Change-Id: I4ac2a8a23809ec1b1b9e42992cd0f3c349848f06
Reviewed-on: https://go-review.googlesource.com/17472
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-05 07:45:01 +00:00
Mikio Hara
d2ca451873 net: adjust Lookup API test cases
This change makes existing Lookup API test cases conform to the new
return value form that all the Lookup APIs except LookupTXT must return
a single or multiple absolute domain names.

Updates #12189.
Fixes #12193.

Change-Id: I03ca09be5bff80e818fbcdc26039daa33d5440a8
Reviewed-on: https://go-review.googlesource.com/17411
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-05 06:19:47 +00:00
Yuval Pavel Zholkover
f25f6eab0c syscall: route_freebsd switch routing socket sysctl to use NET_RT_IFLISTL
Switch IfMsghdr and IfaMsghdr to their 'l' variants, make the IfData layout
to be based on FreeBSD-11.0 (freebsdVersion >= 1100011).
Using freebsdVersion, detect the appropriate layout at runtime and decode
routing socket messages into the new IfData layout.

Fixes #11641

Change-Id: Ic7ec550f00c0d15f46a36f560d835e4f138f61e1
Reviewed-on: https://go-review.googlesource.com/14757
Reviewed-by: Russ Cox <rsc@golang.org>
2015-12-05 04:55:02 +00:00
Russ Cox
a456e356b2 net/url: accept empty port after colon in IPv6 literal host
Fixes #12200.

Change-Id: I89f2a7326bb9182024c44bf815a06fa48639649d
Reviewed-on: https://go-review.googlesource.com/17384
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-05 03:56:55 +00:00
Emmanuel Odeke
c6d660a330 net/http: make TestRedirect also test in http2 mode
Change-Id: Idfbe91abc11b2b3b735cd8d11fb1938f9e5c0473
Reviewed-on: https://go-review.googlesource.com/17437
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-05 00:05:00 +00:00
Emmanuel Odeke
c2290feeeb net/http: sniff tests ported to h2
Change-Id: Icad6cc130252ac177946b23c12f36d6ba3275bf0
Reviewed-on: https://go-review.googlesource.com/17436
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 23:38:27 +00:00
Emmanuel Odeke
2f2423c81d net/http: TimeoutHandler test ported to HTTP/2
Change-Id: I69e62199140e5cf203696af17d4816f3a5f13bd1
Reviewed-on: https://go-review.googlesource.com/17434
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 23:09:35 +00:00
Emmanuel Odeke
983926a728 net/http: testHeadResponses port for h2
Change-Id: I4cf4596a305510cd25df34ecebd11a19266415f1
Reviewed-on: https://go-review.googlesource.com/17435
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 23:09:16 +00:00
Emmanuel Odeke
c498a45b33 net/http: Connection:close test is h1 specific
Change-Id: I77e4df7ab0bc20d2e251c1eda9ce9026484b8bbc
Reviewed-on: https://go-review.googlesource.com/17433
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 21:52:31 +00:00
Burcu Dogan
a8d9c3103d net/http: test max request body size against both HTTP/1 and HTTP/2
Change-Id: I009eaa52d03f1c3af33a6e884332f41c7cf48edd
Reviewed-on: https://go-review.googlesource.com/17427
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 19:54:05 +00:00
Brad Fitzpatrick
1ea31c7baf net/http: convert TestSetsRemoteAddr to use clientServerTest
This is an example of converting an old HTTP/1-only test to test
against both HTTP/1 and HTTP/2.

Please send more of these!

Also, for comparing the http.Transport's responses between HTTP/1 and
HTTP/2, see clientserver_test.go's h12Compare type and tests using
h12Compare. Sometimes that's the more appropriate option.

Change-Id: Iea24d844481efd5849173b60e15dcc561a32b88f
Reviewed-on: https://go-review.googlesource.com/17409
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 19:16:57 +00:00
Russ Cox
e8cc083ede net/mail: do not parse RFC 2047 tokens in quoted strings
RFC 2047 tokens like =?utf-8?B?whatever?= can only appear
unquoted, but this code was trying to decode them even when
they came out of quoted strings. Quoted strings must be left alone.

Fixes #11294.

Change-Id: I41b371f5b1611f1e56d93623888413d07d4ec878
Reviewed-on: https://go-review.googlesource.com/17381
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-04 16:11:09 +00:00
Mikio Hara
8854bdbd76 net: fix parsing literal IPv6 address with zone identifier when using cgo
Parsing literal IPv6 address with zone identifier is already supported
when not using cgo. This change enables it when using cgo too.

Fixes #12241.

Change-Id: I3ed78c9e750e75eff0dae76ba8608df39503cf85
Reviewed-on: https://go-review.googlesource.com/17215
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-12-04 02:50:00 +00:00
Mikio Hara
d41d47306a net/mail: gofmt
Change-Id: Ic704a2614e310bc7aa3bdee89a020c27f4292efa
Reviewed-on: https://go-review.googlesource.com/17410
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-04 02:38:34 +00:00
David du Colombier
cd294636c8 net: return rooted DNS names on Plan 9
This change returns rooted DNS names on Plan 9,
for consistency with other operating systems.

Updates #12193.

Change-Id: If983920c5b9a8f67d4ccb51bb295fac8dfb87e88
Reviewed-on: https://go-review.googlesource.com/15581
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-12-04 01:47:18 +00:00
Brad Fitzpatrick
71d2fa8bae net/http: deflake a non-short test, clean up export_test.go
This makes TestTransportResponseCloseRace much faster and no longer
flaky.

In the process it also cleans up test hooks in net/http which were
inconsistent and scattered.

Change-Id: Ifd0b11dbc7e8915c24eb5bdc36731ed6751dd7ec
Reviewed-on: https://go-review.googlesource.com/17316
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 21:58:29 +00:00
Brad Fitzpatrick
a778ac5d76 net/http: make Client follow redirects even if Request.Method is empty
Fixes #12705

Change-Id: I69639d2b03777835b2697ff349a00ccab410aa49
Reviewed-on: https://go-review.googlesource.com/17318
Reviewed-by: Burcu Dogan <jbd@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-03 19:53:44 +00:00
Benjamin Prosnitz
723605e918 net: fix failing TestGoLookupIPOrderFallbackToFile
Change-Id: I17ef4e221e5cd0fb8dc553785248ccac59380c6f
Reviewed-on: https://go-review.googlesource.com/17321
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 19:01:30 +00:00
Alex Brainman
92cc3c4e76 net: return rooted DNS names on windows
This CL also changes windows LookupSRV to return
_xmpp-server._tcp.google.com. as cname instead of google.com
similar to linux. Otherwise TestLookupDots still fails.

Updates #12193 (with plan9 still to do)

Change-Id: Id225e15bee95037cdb4226803506cce690c5d341
Reviewed-on: https://go-review.googlesource.com/13887
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-03 01:44:43 +00:00
Alexandre Cesaro
69c09afb0d net/mail: add test index to error messages in a recent test
Add the test index so it is easier to find which test case failed.

Change-Id: Ic04682651b26b137355950ff0c51bdbdb1d85a9c
Reviewed-on: https://go-review.googlesource.com/17351
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 22:41:51 +00:00
Alexandre Cesaro
2cb265d16c net/mail: use base64 encoding when needed in Address.String()
When the name of an Address contains non-ASCII characters,
Address.String() used mime.QEncoding to encode the name.

However certain characters are forbidden when an encoded-word is
in a phrase context (see RFC 2047 section 5.3) and these
characters are not encoded by mime.QEncoding.

In this case we now use mime.BEncoding (base64 encoding) so that
forbidden characters are also encoded.

Fixes #11292

Change-Id: I52db98b41ece439295e97d7e94c8190426f499c2
Reviewed-on: https://go-review.googlesource.com/16012
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 17:37:36 +00:00
Brad Fitzpatrick
9bad99574a net/http: enable HTTP/2 on all Transports, not just the DefaultTransport
This mirrors the same behavior and API from the server code to the
client side: if TLSNextProto is nil, HTTP/2 is on by default for
both. If it's non-nil, the user was trying to do something fancy and
step out of their way.

Updates #6891

Change-Id: Ia31808b71f336a8d5b44b985591d72113429e1d4
Reviewed-on: https://go-review.googlesource.com/17300
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 02:03:19 +00:00
Ingo Oeser
a4f057bcc3 net/mail: better errors on non-ascii characters
Fixes #12492

Change-Id: I8bb512027639301e2f2c41aab84e6d06ae88b137
Reviewed-on: https://go-review.googlesource.com/14312
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-02 00:25:15 +00:00
Benjamin Prosnitz
e614d60759 net: fall back to hosts file if DNS lookup fails, despite order
Fixes #13090

Change-Id: I5612d792dabdff89bd0cec57dc2cacf9be7ebf64
Reviewed-on: https://go-review.googlesource.com/16341
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-02 00:15:41 +00:00
Carlos Cirello
5fc583854f net/http/httputil: add package level examples
Change-Id: I5be18b68602a7ebb740cf05924236ce17e386e55
Reviewed-on: https://go-review.googlesource.com/17295
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01 22:25:52 +00:00
Blake Gentry
5dd372bd1e net/http: retry idempotent HTTP reqs on dead reused conns
If we try to reuse a connection that the server is in the process of
closing, we may end up successfully writing out our request (or a
portion of our request) only to find a connection error when we try to
read from (or finish writing to) the socket. This manifests as an EOF
returned from the Transport's RoundTrip.

The issue, among others, is described in #4677.

This change follows some of the Chromium guidelines for retrying
idempotent requests only when the connection has been already been used
successfully and no header data has yet been received for the response.

As part of this change, an unexported error was defined for
errMissingHost, which was previously defined inline. errMissingHost is
the only non-network error returned from a Request's Write() method.

Additionally, this breaks TestLinuxSendfile because its test server
explicitly triggers the type of scenario this change is meant to retry
on. Because that test server stops accepting conns on the test listener
before the retry, the test would time out. To fix this, the test was
altered to use a non-idempotent test type (POST).

Change-Id: I1ca630b944f0ed7ec1d3d46056a50fb959481a16
Reviewed-on: https://go-review.googlesource.com/3210
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-12-01 20:40:31 +00:00
Brad Fitzpatrick
ccdcd6e903 net/http: update h2_bundle.go
Updates to x/net rev 195180cf
(golang.org/cl/17134, http2: merge duplicate Transport dials)

Change-Id: I50b9c73b30c6a21e725aad80126b713d8b0fa362
Reviewed-on: https://go-review.googlesource.com/17261
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-30 20:48:24 +00:00
Burcu Dogan
afc2c45f05 net/http: define File as an io.Seeker
Fixes #13421.

Change-Id: Ic0fc0d0a8e86d2be23db12ddd1a8a8105e26ee56
Reviewed-on: https://go-review.googlesource.com/17250
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-30 20:43:39 +00:00
Mikio Hara
175bfda49f net: fix typo in test
Change-Id: Ibc55e98c43cebe5a21ab3b280489e1bce6405b8b
Reviewed-on: https://go-review.googlesource.com/17218
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-11-29 22:06:08 +00:00
Mikio Hara
4d6a69f227 net: force LookupAddr results to be rooted DNS paths even in the case of local source
The builtin name resolver using various resolution techniques is a bit
complicated and we sometimes fotget to take care of all the go and cgo
code paths and exchanging information to local and remote sources. This
change makes LookupAddr return absolute domain names even in the case of
local source.

Updates #12189.
Fixes #12240.

Change-Id: Icdd3375bcddc7f5d4d3b24f134d93815073736fc
Reviewed-on: https://go-review.googlesource.com/17216
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-28 08:43:55 +00:00
Mikio Hara
85bfa33fdc net: fix case insensitivity lookup for local database such as /etc/hosts
The previous change for #12806 modified internal lookup tables and made
LookupAddr return forcibly lowercased host names by accident.

This change fixes the issue again without any behavioral change for
LookupAddr and adds missing test cases for lookupStaticHost and
lookupStaticAddr.

Updates #12806.
Fixes #13359.

Change-Id: Ifff4741cd79eb8b320b1b0f8c5e02b3a167c9fa8
Reviewed-on: https://go-review.googlesource.com/17217
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-27 22:52:14 +00:00
Brad Fitzpatrick
e91019d253 net/http: add test that automatic gzip works for HTTP2's Transport
And updates h2_bundle.go with the fix from x/net/http2.

Fixes #13298
Updates #6891

Change-Id: Ia25f22fa10e2a64b9d59211269882681aa18c101
Reviewed-on: https://go-review.googlesource.com/17241
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-26 17:15:22 +00:00
Dmitry Vyukov
7b767f4e52 internal/race: add package
Factor out duplicated race thunks from sync, syscall net
and fmt packages into a separate package and use it.

Fixes #8593

Change-Id: I156869c50946277809f6b509463752e7f7d28cdb
Reviewed-on: https://go-review.googlesource.com/14870
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-26 16:50:31 +00:00
Brad Fitzpatrick
e5956bca41 net/http: more HTTP/2 tests and fixes
This compares the behavior of server handlers and the net/http
Transport in both HTTP/1 and HTTP/2 mode and verifies they're the
same.

This also moves some client<->server tests into clientserver_test.go.
Many of them were in serve_test.go or transport_test.go but were
basically testing both.

h2_bundle.go is an update of the golang.org/x/net/http2 code
from https://golang.org/cl/17204 (x/net git rev c745c36eab10)

Fixes #13315
Fixes #13316
Fixes #13317
Fixes other stuff found in the process too
Updates #6891 (http2 support in general)

Change-Id: Id9c45fad44cdf70ac95d2b89e578d66e882d3cc2
Reviewed-on: https://go-review.googlesource.com/17205
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-25 05:18:46 +00:00
Mikio Hara
91977d07fe net: move TestLookupPort into lookup_test.go
No code changes.

Change-Id: Ibbba7c86007d74b853fb59aa742f87783bd69503
Reviewed-on: https://go-review.googlesource.com/16541
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-21 02:59:54 +00:00
Ian Lance Taylor
7e31224329 net: don't run multicast listen test on nil interface in short mode
The gccgo bug report https://gcc.gnu.org/PR65785 points out that the
multicast listen tests will use the network even with -test.short.
Fix test by checking testing.Short with a nil interface.

Change-Id: I7eab8df34fe3b78fc376912312fac9d0f94977f1
Reviewed-on: https://go-review.googlesource.com/17154
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-11-21 01:33:40 +00:00
Brad Fitzpatrick
aae81d948c net/http: start of making all relevant tests test both http1 and http2
This CL adds skipped failing tests, showing differences between HTTP/1
and HTTP/2 behavior. They'll be fixed in later commits.

Only a tiny fraction of the net/http tests have been split into their
"_h1" and "_h2" variants. That will also continue. (help welcome)

Updates #6891
Updates #13315
Updates #13316
Updates #13317

Change-Id: I16c3c381dbe267a3098fb266ab0d804c36473a64
Reviewed-on: https://go-review.googlesource.com/17046
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-19 02:41:20 +00:00
Brad Fitzpatrick
e4a1acced7 net/http: accept empty method in Transport again
Fix regression from https://golang.org/cl/16829 ("require valid methods
in NewRequest and Transport.RoundTrip").

An empty string is a valid method (it means "GET", per the docs).

Fixes #13311

Change-Id: I26b71dc4ccc146498b5d7e38fbe31ed11dd5a6cf
Reviewed-on: https://go-review.googlesource.com/16952
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-19 01:35:36 +00:00
Ian Lance Taylor
9ceb1acbfb net: use t.Fatalf, not t.Fatal, in test
Found by cmd/vet.

Change-Id: Id570ecd76c3f1efd9696680ccd9799610217f8f7
Reviewed-on: https://go-review.googlesource.com/17042
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-18 21:55:38 +00:00
Matthew Dempsky
4d4a266780 net: fix IPv4 address selection
Only apply RFC 6724's CommonPrefixLen rule for IPv4 source/destination
pairs that are members of the same IPv4 special purpose block.

Fixes #13283.

Change-Id: I2f7c26b408dd4675dfc5c1959e22d05b43bb8241
Reviewed-on: https://go-review.googlesource.com/16995
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-17 23:48:43 +00:00
Dan Peterson
f4a9bd87ba net: don't require recursion be available in DNS responses
Fixes #12778

Change-Id: I2ca53180d46180b951749abe453fd560d0f1d9d6
Reviewed-on: https://go-review.googlesource.com/16950
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-17 20:11:22 +00:00
Emmanuel Odeke
8b1152a599 net/http: add/update mp4 sniffing
Completes sniffing for mp4 signature according
to the spec at:
  https://mimesniff.spec.whatwg.org/#signature-for-mp4
Clause 6.2.1

Fixes #8773

Change-Id: Icfc4a23324ae249db52c94a21c0e8509e1833e19
Reviewed-on: https://go-review.googlesource.com/16951
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-17 18:00:15 +00:00
Caleb Spare
babdb38320 net/http: detect when an HTTPS client contacts an HTTP server
Inspect the crypto/tls error to recognize this case and give a more
helpful error.

Fixes #11111.

Change-Id: I63f6af8c375aa892326ccccbd29655d54d68df0b
Reviewed-on: https://go-review.googlesource.com/16079
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-17 04:06:32 +00:00
Marcel van Lohuizen
b4c9ec8be9 net/rpc: verify that embedding works with changed semantics
Exported methods of unexported embedded structs get added
correctly to the pool. Behavior is unchanged before and after
https://golang.org/cl/14085.

Change-Id: I2b4053bab02ff045f0a4577b8114808a60aae27e
Reviewed-on: https://go-review.googlesource.com/16305
Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-13 19:47:35 +00:00
Brad Fitzpatrick
a734a8550a net/http: require valid methods in NewRequest and Transport.RoundTrip
Fixes #12078

Change-Id: If09c927fae639ec4ed3894a2b393a87c1e677803
Reviewed-on: https://go-review.googlesource.com/16829
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-13 10:13:48 +00:00
Brad Fitzpatrick
0b314e1af9 net/http: add method constants
Fixes #12078

Change-Id: Ia8738123b07ca29be4a0cf400ee143729c8b5b3c
Reviewed-on: https://go-review.googlesource.com/16860
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-13 10:12:46 +00:00
Yasuhiro Matsumoto
940d41e386 net: make TestInterfaceList work on non-English Windows
Fixes #13198

The output of netsh is encoded with ANSI encoding. So doesn't match with UTF-8 strings.
Write output as UTF-8 using powershell.

Change-Id: I6c7e93c590ed407f24ae847601d71df9523e028c
Reviewed-on: https://go-review.googlesource.com/16756
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-11-13 01:14:12 +00:00
Yao Zhang
eebf7d279b net/http: fixed TestLinuxSendfile for mips64
mips64 strace doesn't support sendfile64 and will error out if we
specify that with `-e trace='. So we use sendfile for mips64 here.

Change-Id: If5e2bb39866ca3a77dcc40e4db338ba486921d89
Reviewed-on: https://go-review.googlesource.com/14455
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-12 04:50:57 +00:00
Adam Langley
9f08b6c494 crypto/tls: don't send IP literals as SNI values.
(This relands commit a4dcc692011bf1ceca9b1a363fd83f3e59e399ee.)

https://tools.ietf.org/html/rfc6066#section-3 states:

  “Literal IPv4 and IPv6 addresses are not permitted in "HostName".”

However, if an IP literal was set as Config.ServerName (which could
happen as easily as calling Dial with an IP address) then the code would
send the IP literal as the SNI value.

This change filters out IP literals, as recognised by net.ParseIP, from
being sent as the SNI value.

Fixes #13111.

Change-Id: I6e544a78a01388f8fe98150589d073b917087f75
Reviewed-on: https://go-review.googlesource.com/16776
Run-TryBot: Adam Langley <agl@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-10 22:17:16 +00:00
Erik Dubbelboer
d33360571f net/http: Show more data for unsolicited response
Show more than one character when we recieve a unsolicited
response on an idle HTTP channel. Showing more than one
byte is really useful when you want to debug your program
when you get this message.

Change-Id: I3caf9f06420e7c2a2de3e4eb302c5dab95428fdb
Reviewed-on: https://go-review.googlesource.com/13959
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-10 11:04:52 +00:00
Brad Fitzpatrick
e36494e382 net/http/internal: ignore chunk-extension when reading chunked encoding bodies
Fixes #13135

Change-Id: I45666f32cd91102211bf01a306edcb10deb65187
Reviewed-on: https://go-review.googlesource.com/16680
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-10 08:17:58 +00:00
Alex Brainman
c776cb999b net: fix off by one error while counting interfaces on windows
Fixes #12301

Change-Id: I8d01ec9551c6cff7e6129e06a7deb36a3be9de41
Reviewed-on: https://go-review.googlesource.com/16751
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-10 00:53:23 +00:00
Brad Fitzpatrick
11cf5da0e3 net/http: update bundled http2 revision
Updates to git rev 042ba42f (https://golang.org/cl/16734)

This moves all the code for glueing the HTTP1 and HTTP2 transports
together out of net/http and into x/net/http2 where others can use it,
and where it has tests.

Change-Id: I143ac8bb61eed36c87fd838b682ebb37b81b8c2c
Reviewed-on: https://go-review.googlesource.com/16735
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-11-08 15:11:14 +00:00
Brad Fitzpatrick
525d4bd520 net/http: update http2 bundle
To rev a179abb (handle Transport PING frames).

Change-Id: I6e1eef2c9586c23f231803d9364d921248722f12
Reviewed-on: https://go-review.googlesource.com/16732
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-07 16:35:34 +00:00
Brad Fitzpatrick
5e03c84a3d net/http: update http2 bundle to rev d62542
Updates to use new client pool abstraction.

Change-Id: I3552018038ee8394d313d3253af337b07be211f6
Reviewed-on: https://go-review.googlesource.com/16730
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-07 15:51:59 +00:00
Brad Fitzpatrick
4123be4cf6 net/http: enable HTTP/2 support in DefaultTransport
The GODEBUG option remains, for now, but only for turning it off.
We'll decide what to do with it before release.

This CL includes the dependent http2 change (https://golang.org/cl/16692)
in the http2 bundle (h2_bundle.go).

Updates golang/go#6891

Change-Id: If9723ef627c7ba4f7343dc8cb89ca88ef0fbcb10
Reviewed-on: https://go-review.googlesource.com/16693
Reviewed-by: Blake Mizerany <blake.mizerany@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-07 13:35:36 +00:00
Brad Fitzpatrick
e50a4c6987 net/http: register HTTP/2 before listening in ListenAndServe
Change-Id: Icf9b6802945051aa484fb9ebcce71704f5655474
Reviewed-on: https://go-review.googlesource.com/16630
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-04 16:25:18 +00:00
Brad Fitzpatrick
8ee90fad12 syscall: allow nacl's fake network code to Listen twice on the same address
Noticed from nacl trybot failures on new tests in
https://golang.org/cl/16630

Related earlier fix of mine to nacl's listen code:

  syscall: fix nacl listener to not accept connections once closed
  https://go-review.googlesource.com/15940

Perhaps a better fix (in the future?) would be to remove the listener
from the map at close, but that didn't seem entirely straightforward
last time I looked into it. It's not my code, but it seems that the
map entry continues to have a purpose even after Listener close. (?)

But given that this code is only really used for running tests and the
playground, this seems fine.

Change-Id: I43bfedc57c07f215f4d79c18f588d3650687a48f
Reviewed-on: https://go-review.googlesource.com/16650
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-04 16:03:21 +00:00
Brad Fitzpatrick
b1050542c1 net/http: don't panic after request if Handler sets Request.Body to nil
The Server's server goroutine was panicing (but recovering) when
cleaning up after handling a request. It was pretty harmless (it just
closed that one connection and didn't kill the whole process) but it
was distracting.

Updates #13135

Change-Id: I2a0ce9e8b52c8d364e3f4ce245e05c6f8d62df14
Reviewed-on: https://go-review.googlesource.com/16572
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-04 00:00:15 +00:00
Mikio Hara
b50b21d3e1 net: make Dial, Listen{,Packet} for TCP/UDP with invalid port fail
This change makes Dial, Listen and ListenPacket with invalid port fail
whatever GODEBUG=netdns is.

Please be informed that cgoLookupPort with an out of range literal
number may return either the lower or upper bound value, 0 or 65535,
with no error on some platform.

Fixes #11715.

Change-Id: I43f9c4fb5526d1bf50b97698e0eb39d29fd74c35
Reviewed-on: https://go-review.googlesource.com/12447
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-11-01 05:28:17 +00:00
Russ Cox
845878a213 net/http: do not listen on public network during HTTP/2 test
Avoids Mac firewall box.

Change-Id: I000e421fa9639612d636b6fa4baf905459c5aeb2
Reviewed-on: https://go-review.googlesource.com/16514
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-30 18:42:51 +00:00
Brad Fitzpatrick
c229d2fdc6 net/http: update x/net/http2
Updated bundle of golang.org/x/net/http2 to rev c95266

Change-Id: Id6df66a8f4eadd6a100f359fd6cac981653dafa6
Reviewed-on: https://go-review.googlesource.com/16448
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-30 15:50:20 +00:00
Taru Karttunen
2dedb971e3 net/http: extra documentation for Redirect and RedirectHandler
Errors with http.Redirect and http.StatusOk seem
to occur from time to time on the irc channel.
This change adds documentation suggesting
to use one of the 3xx codes and not StatusOk
with Redirect.

Change-Id: I6b900a8eb868265fbbb846ee6a53e426d90a727d
Reviewed-on: https://go-review.googlesource.com/15980
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-29 19:52:45 +00:00
Brad Fitzpatrick
492a62e945 net/http/httputil: add hook for managing io.Copy buffers per request
Adds ReverseProxy.BufferPool for users with sensitive allocation
requirements. Permits avoiding 32 KB of io.Copy garbage per request.

Fixes #10277

Change-Id: I5dfd58fa70a363ead4be56405e507df90d871719
Reviewed-on: https://go-review.googlesource.com/9399
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-28 05:53:28 +00:00
Brad Fitzpatrick
d3f88ce06c net/http/httptest: close conns in StateNew on Server close
This part got dropped when we were debating between two solutions
in https://golang.org/cl/15151

Fixes #13032

Change-Id: I820b94f6c0c102ccf9342abf957328ea01f49a26
Reviewed-on: https://go-review.googlesource.com/16313
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-27 21:18:04 +00:00
Shenghou Ma
9b6069bf98 net/url: fix mentions of URL.EscapedPath method
Fixes #12862.

Change-Id: I6921ae31bd5515f344fd97d08eafc317228b98a0
Reviewed-on: https://go-review.googlesource.com/15590
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-23 22:22:49 +00:00
Joel Sing
46630ecd65 net/http/httptest: fix comment regarding certificate expiry
In earlier versions of Go, times were only encoded as an ASN.1 UTCTIME and
crypto/tls/generate_cert.go limited times to the maximum UTCTIME value.
Revision 050b60a3 added support for ASN.1 GENERALIZEDTIME, allowing larger
time values to be represented (per RFC 5280).

As a result, when the httptest certificate was regenerated in revision
9b2d84ef, the Not After date changed to Jan 29 16:00:00 2084 GMT. Update
the comment to reflect this.

Change-Id: I1bd66e011f2749f9372b5c7506f52ea34e264ce9
Reviewed-on: https://go-review.googlesource.com/16193
Reviewed-by: Adam Langley <agl@golang.org>
2015-10-22 17:31:02 +00:00
Brad Fitzpatrick
3b000b3eae net/http: update copy of http2
Updates to x/net git revision 9946ad7

Change-Id: I95c03daf382667002a5b22f184bd9b7d18144913
Reviewed-on: https://go-review.googlesource.com/16066
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-21 00:28:55 +00:00
Brad Fitzpatrick
09eb58893f net/http: return error from Serve if http2.ConfigureServer returns an error
In https://golang.org/cl/15860 http2.ConfigureServer was changed to
return an error if explicit CipherSuites are listed and they're not
compliant with the HTTP/2 spec.

This is the net/http side of the change, to look at the return value
from ConfigureServer and propagate it in Server.Serve.

h2_bundle.go will be updated in a future CL. There are too many other
http2 changes pending to be worth updating it now. Instead,
h2_bundle.go is minimally updated by hand in this CL so at least the
net/http change will compile.

Updates #12895

Change-Id: I4df7a097faff2d235742c2d310c333bd3fd5c08e
Reviewed-on: https://go-review.googlesource.com/16065
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-20 23:21:23 +00:00
Nodir Turakulov
0bf515c8c4 net/http/httptest: detect Content-Type in ResponseRecorder
* detect Content-Type on ReponseRecorder.Write[String] call
  if header wasn't written yet, Content-Type header is not set and
  Transfer-Encoding is not set.
* fix typos in serve_test.go

Updates #12986

Change-Id: Id2ed8b1994e64657370fed71eb3882d611f76b31
Reviewed-on: https://go-review.googlesource.com/16096
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-20 01:01:22 +00:00
Brad Fitzpatrick
d4d1668864 net/http: add Transport.TLSNextProto, ErrSkipAltProtocol
This is the start of wiring up the HTTP/2 Transport. It is still
disabled in this commit.

This change does two main things:

1) Transport.RegisterProtocol now permits registering "http" or
   "https" (they previously paniced), and the semantics of the
   registered RoundTripper have been extended to say that the new
   sentinel error value (ErrSkipAltProtocol, added in this CL) means
   that the Transport's RoundTrip method proceeds as if the alternate
   protocol had not been registered. This gives us a place to register
   an alternate "https" RoundTripper which gets first dibs on using
   HTTP/2 if there's already a cached connection.

2) adds Transport.TLSNextProto, a map keyed by TLS NPN/ALPN protocol
   strings, similar in feel to the existing Server.TLSNextProto map.
   This map is the glue between the HTTP/1 and HTTP/2 clients, since
   we don't know which protocol we're going to speak (and thus which
   Transport type to use) until we've already made the TCP connection.

Updates #6891

Change-Id: I7328c7ff24f52d9fe4899facabf7ecc5dcb989f3
Reviewed-on: https://go-review.googlesource.com/16090
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-20 00:30:45 +00:00
Brad Fitzpatrick
a3156aaa12 net/http/httptest: change Server to use http.Server.ConnState for accounting
With this CL, httptest.Server now uses connection-level accounting of
outstanding requests instead of ServeHTTP-level accounting. This is
more robust and results in a non-racy shutdown.

This is much easier now that net/http.Server has the ConnState hook.

Fixes #12789
Fixes #12781

Change-Id: I098cf334a6494316acb66cd07df90766df41764b
Reviewed-on: https://go-review.googlesource.com/15151
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-20 00:07:19 +00:00
Nodir Turakulov
88fa2e0be6 net/http: fix typo in serve_test.go
Change-Id: Iaf33fae7043f21df2dba0bb7e1addb0ff002c508
Reviewed-on: https://go-review.googlesource.com/16088
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-19 21:36:09 +00:00
David Crawshaw
996c540be2 net: android no longer supports unix/unixgram
I cannot find any documentation for this, but these tests no longer run
on the device I have since upgrading to Android L. Presumably it still
works for root, but standard Android programs to not have root access.

Change-Id: I001c8fb5ce22f9ff8d7433f881d0dccbf6ab969d
Reviewed-on: https://go-review.googlesource.com/16056
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-10-19 19:27:22 +00:00
Brad Fitzpatrick
a8645e283b net/http: use the correct error variable in serveFile
It was generating the wrong error message, always defaulting to "500
Internal Server Error", since the err variable used was always nil.

Fixes #12991

Change-Id: I94b0e516409c131ff3b878bcb91e65f0259ff077
Reviewed-on: https://go-review.googlesource.com/16060
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-19 15:26:35 +00:00
Yasuharu Goto
dab143c882 net/http: Client support for Expect: 100-continue
Current http client doesn't support Expect: 100-continue request
header(RFC2616-8/RFC7231-5.1.1). So even if the client have the header,
the head of the request body is consumed prematurely.

Those are my intentions to avoid premature consuming body in this change.
- If http.Request header contains body and Expect: 100-continue
  header, it blocks sending body until it gets the first response.
- If the first status code to the request were 100, the request
  starts sending body. Otherwise, sending body will be cancelled.
- Tranport.ExpectContinueTimeout specifies the amount of the time to
  wait for the first response.

Fixes #3665

Change-Id: I4c04f7d88573b08cabd146c4e822061764a7cd1f
Reviewed-on: https://go-review.googlesource.com/10091
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-17 00:44:46 +00:00
Brad Fitzpatrick
368f73bcd9 net: unblock plan9 TCP Read calls after socket close
Fixes #7782
Fixes #9554
Updates #7237 (original metabug, before we switched to specific bugs)
Updates #11932 (plan9 still doesn't have net I/O deadline support)

Change-Id: I96f311b88b1501d884ebc008fd31ad2cf1e16d75
Reviewed-on: https://go-review.googlesource.com/15941
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-16 19:16:56 +00:00
Ilya Tocar
7d86d57444 net: use IndexByte implementation from runtime package
In net/parse.go we reimplement bytes.IndexByte and strings.IndexByte,
However those are implemented in runtime/$GOARCH_asm.s.
Using versions from runtime should provide performance advantage,
and keep the same code together.

Change-Id: I6212184bdf6aa1f2c03ce26d4b63f5b379d8ed0c
Reviewed-on: https://go-review.googlesource.com/15953
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-16 16:58:52 +00:00
Brad Fitzpatrick
19aa4209ae syscall: fix nacl listener to not accept connections once closed
Change-Id: I3ba6e97089ef6e69ba31dfb632df465859906a74
Reviewed-on: https://go-review.googlesource.com/15940
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-10-16 14:43:17 +00:00
Brad Fitzpatrick
d3ae2d2749 net/http/cgi: optimize internal function removeLeadingDuplicates a bit
Change-Id: I0255f24f5c5925ea4daa28a28d23606df35d4373
Reviewed-on: https://go-review.googlesource.com/15824
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-15 14:42:11 +00:00
Aaron Jacobs
9f60a0a2b0 net/http/httputil: clarify where DumpRequest(Out)? can be used.
The clues to this were already there, but as a user I was still unsure.
Make this more explicit.

Change-Id: I68564f3498dcd4897772a303588f03a6b65f111d
Reviewed-on: https://go-review.googlesource.com/15172
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-14 23:37:12 +00:00
Brad Fitzpatrick
20736fcab9 net/http: enable automatic HTTP/2 if TLSNextProto is nil
This enables HTTP/2 by default (for https only) if the user didn't
configure anything in their NPN/ALPN map. If they're using SPDY or an
alternate http2 or a newer http2 from x/net/http2, we do nothing
and don't use the standard library's vendored copy of x/net/http2.

Upstream remains golang.org/x/net/http2.

Update #6891

Change-Id: I69a8957a021a00ac353f9d7fdb9a40a5b69f2199
Reviewed-on: https://go-review.googlesource.com/15828
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-14 23:21:57 +00:00
Brad Fitzpatrick
7a3dcd2d0f vendor: import golang.org/x/net/http2
golang.org/x/net/http2 becomes net/http/h2_bundle.go (using adonovan's
x/tools/cmd/bundle tool), becoming a hidden part of the net/http package.

golang.org/x/net/http2/hpack becomes vendor/golang.org/x/net/http2/hpack.

At git rev 7331ef52 (https://go-review.googlesource.com/15821)

Change-Id: Ia6683e6f91a481b11a778638bf65b6a338744eea
Reviewed-on: https://go-review.googlesource.com/15822
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-10-14 23:21:40 +00:00
David Glasser
b58515baba net/http: don't hang if RemoteAddr() blocks
The PROXY protocol is supported by several proxy servers such as haproxy
and Amazon ELB.  This protocol allows services running behind a proxy to
learn the remote address of the actual client connecting to the proxy,
by including a single textual line at the beginning of the TCP
connection.
http://www.haproxy.org/download/1.5/doc/proxy-protocol.txt

There are several Go libraries for this protocol (such as
https://github.com/armon/go-proxyproto), which operate by wrapping a
net.Conn with an implementation whose RemoteAddr method reads the
protocol line before returning. This means that RemoteAddr is a blocking
call.

Before this change, http.Serve called RemoteAddr from the main Accepting
goroutine, not from the per-connection goroutine. This meant that it
would not Accept another connection until RemoteAddr returned, which is
not appropriate if RemoteAddr needs to do a blocking read from the
socket first.

Fixes #12943.

Change-Id: I1a242169e6e4aafd118b794e7c8ac45d0d573421
Reviewed-on: https://go-review.googlesource.com/15835
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-14 22:26:38 +00:00
Steven Hartland
61860508ad net/http/cgi: make provided Env override even system env vars
Allow all CGI environment settings from the inherited set and default
inherited set to be overridden including PATH by Env.

Change-Id: Ief8d33247b879fa87a8bfd6416d4813116db98de
Reviewed-on: https://go-review.googlesource.com/14959
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-14 15:10:09 +00:00
Brad Fitzpatrick
2d823fdebf net/http: ignore Transfer-Encoding for HTTP/1.0 responses
Fixes #12785

Change-Id: Iae4383889298c6a78b1ba41bd2cda70b0758fcba
Reviewed-on: https://go-review.googlesource.com/15737
Reviewed-by: Andrew Gerrand <adg@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-13 01:04:42 +00:00
Brad Fitzpatrick
8dd52cf03a net/http: export the "new" error codes from RFC 6585
These were proposed in the RFC over three years ago, then proposed to
be added to Go in https://codereview.appspot.com/7678043/ 2 years and
7 months ago, and the spec hasn't been updated or retracted the whole
time.

Time to export them.

Of note, HTTP/2 uses code 431 (Request Header Fields Too Large).

Updates #12843

Change-Id: I78c2fed5fab9540a98e845ace73f21c430a48809
Reviewed-on: https://go-review.googlesource.com/15732
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-12 22:35:31 +00:00
Didier Spezia
6f772787f9 net/textproto: properly trim continued lines in MIME headers
A MIME header can include values defined on several lines.
Only the first line of each value was trimmed.

Make sure all the lines are trimmed before being aggregated.

Fixes #11204

Change-Id: Id92f384044bc6c4ca836e5dba2081fe82c82dc85
Reviewed-on: https://go-review.googlesource.com/15683
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-11 16:46:15 +00:00
Dave Cheney
fb3f152c19 net/url: make *url.Error implement net.Error
Fixes #12866

net/http.Client returns some errors wrapped in a *url.Error. To avoid
the requirement to unwrap these errors to determine if the cause was
temporary or a timeout, make *url.Error implement net.Error directly.

Change-Id: I1ba84ecc7ad5147a40f056ff1254e60290152408
Reviewed-on: https://go-review.googlesource.com/15672
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-10 11:32:58 +00:00
Brad Fitzpatrick
ae315999c2 net/http/httputil: clarify NewSingleHostReverseProxy's Host header behavior
Fixes #10342

Change-Id: I69c69352016a8fd0b62541128c2e86b242ebbe26
Reviewed-on: https://go-review.googlesource.com/15630
Reviewed-by: Minux Ma <minux@golang.org>
2015-10-08 23:15:40 +00:00
Ian Lance Taylor
f23c37f67a net: remove imports of strconv
The net package already has support for limited uses of the strconv
package.  Despite this, a few uses of strconv have crept in over time.
Remove them and use the existing net support instead.

Change-Id: Icdb4bdaa8e1197f1119a96cddcf548ed4a551b74
Reviewed-on: https://go-review.googlesource.com/15400
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-10-05 22:39:12 +00:00
Kenny Grant
4a6326e7b5 net/http: add response body to 413 and 400 errors
The existing serve() method returns a zero-length response body when
it encounters an error, which results in a blank page and no visible
error in browsers.

This change sends a response body explaining the error for display in browsers.

Fixes #12745

Change-Id: I9dc3b95ad88cb92c18ced51f6b52bd3b2c1b974c
Reviewed-on: https://go-review.googlesource.com/15018
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-05 17:31:36 +00:00
Burcu Dogan
d96a3a2d11 net: make /etc/hosts lookups case-insensitive
The native Go host resolver was behaving differently than libc
and the entries in the /etc/hosts were handled in a case sensitive
way. In order to be compatible with libc's resolver, /etc/hosts
lookups must be case-insensitive.

Fixes #12806.

Change-Id: I3c14001abffadf7458fd1a027c91e6438a87f285
Reviewed-on: https://go-review.googlesource.com/15321
Run-TryBot: Burcu Dogan <jbd@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-10-01 20:52:54 +00:00
Didier Spezia
b7fa4f27ba net/http/fcgi: fix panic with malformed params record
As stated in FastCGI specifications:

FastCGI transmits a name-value pair as the length of the name,
followed by the length of the value, followed by the name,
followed by the value.

The current implementation trusts the name and value length
provided in the record, leading to a panic if the record
is malformed.

Added an explicit check on the lengths.

Test case and fix suggested by diogin@gmail.com (Jingcheng Zhang)

Fixes #11824

Change-Id: I883a1982ea46465e1fb02e0e02b6a4df9e529ae4
Reviewed-on: https://go-review.googlesource.com/15015
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-27 06:57:03 +00:00
Tarmigan Casebolt
e643dc79d4 net: check 'ok' return in dnsmsg when initially packing rr.Header()
In the present code, there is no way for ok to ever return false, but
it still a good idea to check it.

Change-Id: I8f360018b33a5d85dabbbbec0f89ffc81f77ecbb
Reviewed-on: https://go-review.googlesource.com/13956
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-20 02:55:16 +00:00
Brad Fitzpatrick
19d262ffdf net: remove named parameters in Listener.Accept doc signature
They added no value.

Change-Id: I9e690379d2dfd983266de0ea5231f2b57c8b1517
Reviewed-on: https://go-review.googlesource.com/14568
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-09-15 04:07:24 +00:00
Rob Pike
67ddae87b9 all: use one 'l' when cancelling everywhere except Solaris
Fixes #11626.

Change-Id: I1b70c0844473c3b57a53d7cca747ea5cdc68d232
Reviewed-on: https://go-review.googlesource.com/14526
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-11 18:31:51 +00:00
Paul Marks
5a3ff6c895 net: Make Listen(":port") use IPv6 when IPv4 is not supported.
When running an experimental kernel with IPv4 disabled, Listen(":port")
currently tries to create an AF_INET socket, and fails.  Instead, it
should see !supportsIPv4, and use an AF_INET6 socket.

This sort of environment is quite esoteric at the moment, but I can
force the tests to fail on regular Linux using the following tweaks:

- net/net.go: supportsIPv4, supportsIPv6, supportsIPv4map = false, true, false
- net/sockopt_linux.go: ipv6only=true
- net/ipsock_posix.go: Revert this fix
- ./make.bash && ../bin/go test net

Also, make the arrows in server_test.go point to the left, because
server<-client is easier to read.

Fixes #12510

Change-Id: I0cc3b6b08d5e6908d2fbf8594f652ba19815aa4b
Reviewed-on: https://go-review.googlesource.com/14334
Run-TryBot: Paul Marks <pmarks@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-05 02:31:22 +00:00
Dan Peterson
ced0646fe5 net: make DNSError.Temporary return true on SERVFAIL
Fixes #8434

Change-Id: I323222b4160f3aba35cac1de7f6df93c524b72ec
Reviewed-on: https://go-review.googlesource.com/14169
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-04 17:53:54 +00:00
Artyom Pervukhin
6fd82d83d6 net/http: optimize some io.Copy calls by reusing buffers
Optimize two calls of io.Copy which cannot make use of neither
io.ReaderFrom nor io.WriterTo optimization tricks by replacing them with
io.CopyBuffer with reusable buffers.

First is fallback call to io.Copy when server misses the optimized case
of using sendfile to copy from a regular file to net.TCPConn; second is
use of io.Copy on piped reader/writer when handler implementation uses
http.CloseNotifier interface. One of the notable users of
http.CloseNotifier is httputil.ReverseProxy.

benchmark                    old ns/op     new ns/op     delta
BenchmarkCloseNotifier-4     309591        303388        -2.00%

benchmark                    old allocs     new allocs     delta
BenchmarkCloseNotifier-4     50             49             -2.00%

benchmark                    old bytes     new bytes     delta
BenchmarkCloseNotifier-4     36168         3140          -91.32%

Fixes #12455

Change-Id: I512e6aa2f1aeed2ed00246afb3350c819b65b87e
Reviewed-on: https://go-review.googlesource.com/14177
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-04 17:44:29 +00:00
Nodir Turakulov
8c2c35debe net/http/httptest: ResponseRecorder.WriteString
Fixes #11000

Change-Id: Ic137e8a6c5c6b5b7eee213aca9acf78368e1d686
Reviewed-on: https://go-review.googlesource.com/14296
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-04 17:23:41 +00:00
Rob Pike
37025536c3 net/rpc: don't exit if Accept gets an error
The default implementation of Accept, which spins up a new server
for every new connection, calls log.Fatal if the listener is closed,
stopping any outstanding work. Change that to a non-fatal log
call so work can continue.

There is no programmatic signaling of the problem, just the log,
but that should be enough.

Fixes #11221.

Change-Id: I7c7f6164a0a0143236729eb778d7638c51c34ed1
Reviewed-on: https://go-review.googlesource.com/14185
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-09-03 21:17:08 +00:00
Dan Peterson
25b00177af net/http: make FileServer sort directory entries
Fixes #11879

Change-Id: If021f86b2764e01c69674e6a423699b822596f15
Reviewed-on: https://go-review.googlesource.com/14161
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-09-01 20:11:22 +00:00
Paul Marks
754d4c052a net: Increase the acceptable delay in TestDialerDualstack
This may fix the flakiness on Windows/x64, assuming that it's actually
due to a variance in the connection time which slightly exceeds 100ms.

150ms + 95ms = 245ms, which is still low enough to avoid triggering
Happy Eyeballs (300ms) on non-Windows platforms.

Updates #12309

Change-Id: I816a36fbc0a3e5c90e3cf1b75a134faf0d91557c
Reviewed-on: https://go-review.googlesource.com/14120
Run-TryBot: Paul Marks <pmarks@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-31 21:36:04 +00:00
Shenghou Ma
5f2c420eb6 net: add -lsendfile to cgo LDFLAGS for solaris
Fixes external linking of net/http tests (or anything that uses
sendfile).

Fixes #12390.

Change-Id: Iee08998cf66e7b0ce851db138a00ebae6dc2395e
Reviewed-on: https://go-review.googlesource.com/14072
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Aram Hăvărneanu <aram@mgk.ro>
2015-08-30 22:01:07 +00:00
Russ Cox
35365b97f1 net: restore LookupPort for integer strings
This worked in Go 1.4 but was lost in the "pure Go" lookup
routines substituted late in the Go 1.5 cycle.

Fixes #12263.

Change-Id: I77ec9d97cd8e67ace99d6ac965e5bc16c151ba83
Reviewed-on: https://go-review.googlesource.com/13915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-27 16:17:21 +00:00
Brad Fitzpatrick
a34b8cb733 net/http/httputil: permit nil request body in ReverseProxy
Accepting a request with a nil body was never explicitly supported but
happened to work in the past.

This doesn't happen in most cases because usually people pass
a Server's incoming Request to the ReverseProxy's ServeHTTP method,
and incoming server requests are guaranteed to have non-nil bodies.

Still, it's a regression, so fix.

Fixes #12344

Change-Id: Id9a5a47aea3f2875d195b66c9a5f8581c4ca2aed
Reviewed-on: https://go-review.googlesource.com/13935
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-26 20:28:07 +00:00
Todd Neal
c1aee8c825 net/http: remove always true comparison
byte is unsigned so the comparison against zero is always true.

Change-Id: I8fa60245972be362ae920507a291f92c0f9831ad
Reviewed-on: https://go-review.googlesource.com/13941
Run-TryBot: Todd Neal <todd@tneal.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-26 04:55:58 +00:00
Matt Layher
759210b962 net: allow ParseMAC to parse 20-octet IPoIB link-layer address
Fixes #11763

Change-Id: Ie291b36a8c29694e80940836d7e6fd96d2d76494
Reviewed-on: https://go-review.googlesource.com/12382
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-24 16:34:43 +00:00
Mikio Hara
c049d34006 net: drop redundant domain name length check
It is already validated by isDoaminName.

Change-Id: I7a955b632a5143e16b012641cf12bad452900753
Reviewed-on: https://go-review.googlesource.com/13789
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-23 10:43:46 +00:00
Rob Pike
f62b749ae2 all: fix some vet-caught formatting errors, mostly but not only in tests
Could go in 1.5, although not critical.
See also #12107

Change-Id: I7f1608b58581d21df4db58f0db654fef79e33a90
Reviewed-on: https://go-review.googlesource.com/13481
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-08-21 05:37:36 +00:00
Andrew Gerrand
b733234856 net/http: document that [ListenAnd]Serve always returns a non-nil error
Fixes #12229

Change-Id: I243e39f67748e6754fb7726b21b3afc1ff436771
Reviewed-on: https://go-review.googlesource.com/13780
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-20 12:13:41 +00:00
Russ Cox
773b9b8452 net: respect go vs cgo resolver selection in all lookup routines
This is especially important for LookupAddr, which used to be pure Go
(lightweight, one goroutine per call) and without this CL is now
unconditionally cgo (heavy, one thread per call).

Fixes #12190.

Change-Id: I43436a942bc1838b024225893e156f280a1e80cf
Reviewed-on: https://go-review.googlesource.com/13698
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-19 04:20:37 +00:00
Russ Cox
18d27b2d75 net: force LookupAddr results to be rooted DNS paths when using cgo
Go 1.4 and before have always returned DNS names with a trailing dot
for reverse lookups, as they do for basically all other routines returning
DNS names. Go 1.4 and before always implemented LookupAddr using
pure Go (not C library calls).

Go 1.5 added the ability to make a C library call to implement LookupAddr.
Unfortunately the C library call returns a DNS name without a trailing dot
(an unrooted name), meaning that if turn off cgo during make.bash then
you still get the rooted name but with cgo on you get an unrooted name.
The unrooted name is inconsistent with the pure Go implementation
and with all previous Go releases, so change it to a rooted name.

Fixes #12189.

Change-Id: I3d6b72277c121fe085ea6af30e5fe8019fc490ad
Reviewed-on: https://go-review.googlesource.com/13697
Reviewed-by: Rob Pike <r@golang.org>
2015-08-19 04:20:27 +00:00
Russ Cox
b711f5ad8f net: document GODEBUG=netdns=xxx settings
Fixes #12191.

Change-Id: I5c7659ccb0566dad3613041d9e76be87ceacae61
Reviewed-on: https://go-review.googlesource.com/13700
Reviewed-by: Rob Pike <r@golang.org>
2015-08-19 04:08:34 +00:00
Brad Fitzpatrick
d931716cde net/http: fix races cloning TLS config
Found in a Google program running under the race detector.
No test, but verified that this fixes the race with go run -race of:

	package main

	import (
	        "crypto/tls"
	        "fmt"
	        "net"
	        "net/http"
	        "net/http/httptest"
	)

	func main() {
	        for {
	                ts := httptest.NewTLSServer(http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {}))
	                conf := &tls.Config{} // non-nil
	                a, b := net.Pipe()
	                go func() {
	                        sconn := tls.Server(a, conf)
	                        sconn.Handshake()
	                }()
	                tr := &http.Transport{
	                        TLSClientConfig: conf,
	                }
	                req, _ := http.NewRequest("GET", ts.URL, nil)
	                _, err := tr.RoundTrip(req)
	                println(fmt.Sprint(err))
	                a.Close()
	                b.Close()
	                ts.Close()
	        }
	}

Also modified cmd/vet to report the copy-of-mutex bug statically
in CL 13646, and fixed two other instances in the code found by vet.
But vet could not have told us about cloneTLSConfig vs cloneTLSClientConfig.

Confirmed that original report is also fixed by this.

Fixes #12099.

Change-Id: Iba0171549e01852a5ec3438c25a1951c98524dec
Reviewed-on: https://go-review.googlesource.com/13453
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2015-08-18 00:55:16 +00:00
David Symonds
1052b43213 net/mail: fix build.
Change-Id: I8f5c72c6c0db015c06d564523bab35d97d934578
Reviewed-on: https://go-review.googlesource.com/13510
Reviewed-by: Michael McGreevy <mcgreevy@golang.org>
Reviewed-by: David Symonds <dsymonds@golang.org>
2015-08-11 06:42:12 +00:00
David Symonds
1d75b40de8 net/mail: avoid panic in (*Address).String for malformed addresses.
Fixes #12098.

Change-Id: I190586484cd34856dccfafaba60eff0197c7dc20
Reviewed-on: https://go-review.googlesource.com/13500
Reviewed-by: Rob Pike <r@golang.org>
2015-08-11 05:07:30 +00:00
Russ Cox
fced03a5c6 net/url: allow all valid host chars in RawPath
The old code was only allowing the chars we choose not to escape.
We sometimes prefer to escape chars that do not strictly need it.
Allowing those to be used in RawPath lets people override that
preference, which is in fact the whole point of RawPath (new in Go 1.5).

While we are here, also allow [ ] in RawPath.
This is not strictly spec-compliant, but it is what modern browers
do and what at least some people expect, and the [ ] do not cause
any ambiguity (the usual reason they would be escaped, as they are
part of the RFC gen-delims class).
The argument for allowing them now instead of waiting until Go 1.6
is that this way RawPath has one fixed meaning at the time it is
introduced, that we should not need to change or expand.

Fixes #5684.

Change-Id: If9c82a18f522d7ee1d10310a22821ada9286ee5c
Reviewed-on: https://go-review.googlesource.com/13258
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-06 02:59:16 +00:00
Russ Cox
e8be9a170c net/url: do not percent-encode valid host characters
The code in question was added as part of allowing zone identifiers
in IPv6 literals like http://[ipv6%zone]:port/foo, in golang.org/cl/2431.

The old condition makes no sense. It refers to §3.2.1, which is the wrong section
of the RFC, it excludes all the sub-delims, which §3.2.2 (the right section)
makes clear are valid, and it allows ':', which is not actually valid,
without an explanation as to why (because we keep :port in the Host field
of the URL struct).

The new condition allows all the sub-delims, as specified in RFC 3986,
plus the additional characters [ ] : seen in IP address literals and :port suffixes,
which we also keep in the Host field.

This allows mysql://a,b,c/path to continue to parse, as it did in Go 1.4 and earlier.

This CL does not break any existing tests, suggesting the over-conservative
behavior was not intended and perhaps not realized.

It is especially important not to over-escape the host field, because
Go does not unescape the host field during parsing: it rejects any
host field containing % characters.

Fixes #12036.

Change-Id: Iccbe4985957b3dc58b6dfb5dcb5b63a51a6feefb
Reviewed-on: https://go-review.googlesource.com/13254
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-08-06 02:55:37 +00:00
Russ Cox
fc22331ccd net/url: restrict :port checking to [ipv6]:port form
Go 1.4 and earlier accepted mysql://x@y(z:123)/foo
and I don't see any compelling reason to break that.

The CL during Go 1.5 that broke this syntax was
trying to fix #11208 and was probably too aggressive.
I added a test case for #11208 to make sure that stays
fixed.

Relaxing the check did not re-break #11208 nor did
it cause any existing test to fail. I added a test for the
mysql://x@y(z:123)/foo syntax being preserved.

Fixes #12023.

Change-Id: I659d39f18c85111697732ad24b757169d69284fc
Reviewed-on: https://go-review.googlesource.com/13253
Reviewed-by: Andrew Gerrand <adg@golang.org>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2015-08-06 02:55:03 +00:00
Jed Denlea
26049f6f91 net/http: close server conn after broken trailers
Prior to this change, broken trailers would be handled by body.Read, and
an error would be returned to its caller (likely a Handler), but that
error would go completely unnoticed by the rest of the server flow
allowing a broken connection to be reused.  This is a possible request
smuggling vector.

Fixes #12027.

Change-Id: I077eb0b8dff35c5d5534ee5f6386127c9954bd58
Reviewed-on: https://go-review.googlesource.com/13148
Reviewed-by: Russ Cox <rsc@golang.org>
2015-08-05 19:30:24 +00:00
Brad Fitzpatrick
e3c26b2b32 net/http: deflake TestZeroLengthPostAndResponse
It was failing with multiple goroutines a few out of every thousand
runs (with errRequestCanceled) because it was using the same
*http.Request for all 5 RoundTrips, but the RoundTrips' goroutines
(notably the readLoop method) were all still running, sharing that
same pointer. Because the response has no body (which is what
TestZeroLengthPostAndResponse tests), the readLoop was marking the
connection as reusable early (before the caller read until the body's
EOF), but the Transport code was clearing the Request's cancelation
func *AFTER* the caller had already received it from RoundTrip. This
let the test continue looping and do the next request with the same
pointer, fetch a connection, and then between getConn and roundTrip
have an invariant violated: the Request's cancelation func was nil,
tripping this check:

        if !pc.t.replaceReqCanceler(req.Request, pc.cancelRequest) {
                pc.t.putIdleConn(pc)
                return nil, errRequestCanceled
        }

The solution is to clear the request cancelation func in the readLoop
goroutine in the no-body case before it's returned to the caller.

This now passes reliably:

$ go test -race -run=TestZeroLengthPostAndResponse -count=3000

I think we've only seen this recently because we now randomize scheduling
of goroutines in race mode (https://golang.org/cl/11795). This race
has existed for a long time but the window was hard to hit.

Change-Id: Idb91c582919f85aef5b9e5ef23706f1ba9126e9a
Reviewed-on: https://go-review.googlesource.com/13070
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-03 16:06:52 +00:00
Brad Fitzpatrick
7aa4e29dce net/http: fix server/transport data race when sharing the request body
Introduced in https://go-review.googlesource.com/12865 (git rev c2db5f4c).

This fix doesn't add any new lock acquistions: it just moves the
existing one taken by the unreadDataSize method and moves it out
wider.

It became flaky at rev c2db5f4c, but now reliably passes again:
$ go test -v -race -run=TestTransportAndServerSharedBodyRace -count=100 net/http

Fixes #11985

Change-Id: I6956d62839fd7c37e2f7441b1d425793f4a0db30
Reviewed-on: https://go-review.googlesource.com/12909
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-08-03 16:06:17 +00:00
Jed Denlea
c2db5f4ccc net/http: close server conn after request body error
HTTP servers attempt to entirely consume a request body before sending a
response.  However, when doing so, it previously would ignore any errors
encountered.

Unfortunately, the errors triggered at this stage are indicative of at
least a couple problems: read timeouts and chunked encoding errors.
This means properly crafted and/or timed requests could lead to a
"smuggled" request.

The fix is to inspect the errors created by the response body Reader,
and treat anything other than io.EOF or ErrBodyReadAfterClose as
fatal to the connection.

Fixes #11930

Change-Id: I0bf18006d7d8f6537529823fc450f2e2bdb7c18e
Reviewed-on: https://go-review.googlesource.com/12865
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-08-02 09:34:59 +00:00
Carl Jackson
ec4d06e470 net/http: fix SetKeepAlivesEnabled receiver name
This makes the receiver name consistent with the rest of the methods on
type Server.

Change-Id: Ic2a007d3b5eb50bd87030e15405e9856109cf590
Reviewed-on: https://go-review.googlesource.com/13035
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-08-02 08:34:04 +00:00
MathiasB
bd1efd5099 net/mail: fixed quoted-local
Fixes some minor issues regarding quoted-string when parsing
the local-part.

Those strings should return an error:
- quoted-string without any content: `""@test.com`
- quoted-string containing tab: "\"\t\"@test.com"

Fixes #11293

Change-Id: Ied93eb6831915c9b1f8e727cea14168af21f8d3b
Reviewed-on: https://go-review.googlesource.com/12905
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-31 16:11:21 +00:00
Russ Cox
48b4263efa net: allow longer timeout in dialClosedPort test on windows
The test expects the dial to take 1.0 seconds
on Windows and allows it to go to 1.095 seconds.
That's far too optimistic.
Recent failures are reporting roughly 1.2 seconds.
Let it have 1.5.

Change-Id: Id69811ccb65bf4b4c159301a2b4767deb6ee8d28
Reviewed-on: https://go-review.googlesource.com/12895
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-07-30 15:19:17 +00:00
Mikio Hara
80abe2fc59 net: make spuriousENOTAVAIL to be able to parse EADDRNOTAVAIL correctly
Change-Id: I82e3aadbd18fccb98a76d1c36876510f5e1c3089
Reviewed-on: https://go-review.googlesource.com/12750
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-28 11:52:56 +00:00
Mikio Hara
6aa48a9a0b net: don't return DNS query results including the second best records unconditionally
This change prevents DNS query results using domain search list
overtaking results not using the list unconditionally, which only
happens when using builtin DNS stub resolver.

The previous internal lookup function lookup is split into lookup and
goLookupIPOrder for iteration over a set of names: FQDN or absolute
FQDN, with domain label suffixes in search list, without domain label
suffixes, and for concurrent A and AAAA record queries.

Fixes #11081.

Change-Id: I9ff0640f69276e372d97e709b149ed5b153e8601
Reviewed-on: https://go-review.googlesource.com/10836
Reviewed-by: Russ Cox <rsc@golang.org>
2015-07-28 08:39:26 +00:00
Brad Fitzpatrick
d1cf5b899d net/http: disable new flaky TestTransportCancelBeforeResponseHeaders test
I'll rewrite this later. It's apparently dependent on scheduling order.
The earlier fix in git rev 9d56c181 seems fine, though.

Update #11894

Change-Id: I7c150918af4be079c262a5f2933ef4639cc535ef
Reviewed-on: https://go-review.googlesource.com/12731
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-07-28 05:36:52 +00:00
Paul Marks
85a5fce7ad net: Set finalDeadline from TestDialParallel to avoid leaked sockets.
I've also changed TestDialSerialAsyncSpuriousConnection for consistency,
although it always computes a finalDeadline of zero.

Note that #11225 is the root cause of the socket leak; this just hides
it from the unit test by restoring the shorter timeout.

Fixes #11878

Change-Id: Ie0037dd3bce6cc81d196765375489f8c61be74c2
Reviewed-on: https://go-review.googlesource.com/12712
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Paul Marks <pmarks@google.com>
2015-07-28 05:04:36 +00:00
Matthew Dempsky
a01d90744f all: cleanup usage of dashes in package documentation
Change-Id: I58453f7ed71eaca15dd3f501e4ae88d1fab19908
Reviewed-on: https://go-review.googlesource.com/12683
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2015-07-28 02:44:41 +00:00
Brad Fitzpatrick
a3ffd836a6 net/http: pause briefly after closing Server connection when body remains
From https://github.com/golang/go/issues/11745#issuecomment-123555313
this implements option (b), having the server pause slightly after
sending the final response on a TCP connection when we're about to close
it when we know there's a request body outstanding. This biases the
client (which might not be Go) to prefer our response header over the
request body write error.

Updates #11745

Change-Id: I07cb0b74519d266c8049d9e0eb23a61304eedbf8
Reviewed-on: https://go-review.googlesource.com/12658
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-07-27 22:13:08 +00:00