1
0
mirror of https://github.com/golang/go synced 2024-10-04 17:21:20 -06:00
Commit Graph

48 Commits

Author SHA1 Message Date
Brad Fitzpatrick
8476d4cf29 net/http: document Response.Body Read+Close interaction with keep-alive
Fixes #5645

Change-Id: Ifb46d6faf7ac838792920f6fe00912947478e761
Reviewed-on: https://go-review.googlesource.com/1531
Reviewed-by: David Symonds <dsymonds@golang.org>
2014-12-13 10:18:18 +00:00
Brad Fitzpatrick
0e4ee0c9bf net/http: fix timer leak in Transport when using ResponseHeaderTimeout
Fixes #9104

Change-Id: Ide5ac70215d73278e6910f5b9c7687ad7734c0be
Reviewed-on: https://go-review.googlesource.com/1530
Reviewed-by: David Symonds <dsymonds@golang.org>
2014-12-13 07:48:24 +00:00
Brad Fitzpatrick
e67a39ed08 net/http: avoid some allocations in DetectContentType
Change-Id: I64985f8de7ca09e63208e8c949a5d4f4fc09073f
Reviewed-on: https://go-review.googlesource.com/1230
Reviewed-by: David Symonds <dsymonds@golang.org>
2014-12-09 02:00:09 +00:00
Nigel Tao
891abf9cc7 net/http: add comment to clarify whether Dir is '/' or '\'.
LGTM=bradfitz
R=bradfitz, alex.brainman
CC=golang-codereviews
https://golang.org/cl/168600044
2014-11-14 11:43:01 +11:00
Brad Fitzpatrick
38ea0ae05f net/url: add example of using URL.Opaque with http.Request
Per private thread soliciting help. I realized part of this is
documented in several places, but we lacked a unifying
example.

LGTM=rsc
R=golang-codereviews
CC=adg, golang-codereviews, iant, rsc
https://golang.org/cl/171620043
2014-11-12 14:27:27 -08:00
Andrew Gerrand
7f0be1f781 all: use golang.org/x/... import paths
LGTM=rsc, r
R=r, rsc
CC=golang-codereview, golang-codereviews
https://golang.org/cl/168050043
2014-11-10 09:15:57 +11:00
Brad Fitzpatrick
cf105e2fa0 net/http: fix benchmark goroutine leak
New detection because of net/http now using TestMain.

Fixes #9033

LGTM=iant
R=golang-codereviews, iant
CC=adg, golang-codereviews, rsc
https://golang.org/cl/170210043
2014-11-08 15:13:28 -03:00
Ian Lance Taylor
8985c091e4 net/http: add missing newline in list of leaked goroutines
LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/168860044
2014-10-31 10:20:36 -07:00
Mikio Hara
21a9141ab3 net: add test for lookupIPDeadline
Just to confirm the fix, by typing the follwing:
go test -run=TestLookupIPDeadline -dnsflood or
go test -run=TestLookupIPDeadline -dnsflood -tags netgo

Update #8602

LGTM=iant
R=iant
CC=golang-codereviews
https://golang.org/cl/166740043
2014-10-28 16:20:49 +09:00
Ian Lance Taylor
77595e462b net: if a DNS lookup times out, forget that it is in flight
Before this CL, if the system resolver does a very slow DNS
lookup for a particular host, all subsequent requests for that
host will hang waiting for that lookup to complete.  That is
more or less expected when Dial is called with no deadline.
When Dial has a deadline, though, we can accumulate a large
number of goroutines waiting for that slow DNS lookup.  Try to
avoid this problem by restarting the DNS lookup when it is
redone after a deadline is passed.

This CL also avoids creating an extra goroutine purely to
handle the deadline.

No test because we would have to simulate a slow DNS lookup
followed by a fast DNS lookup.

Fixes #8602.

LGTM=bradfitz
R=bradfitz, mikioh.mikioh
CC=golang-codereviews, r, rsc
https://golang.org/cl/154610044
2014-10-27 08:46:18 -07:00
Russ Cox
c5943c668b net/http/pprof: run GC for /debug/pprof/heap?gc=1
We force runtime.GC before WriteHeapProfile with -test.heapprofile.
Make it possible to do the same with the HTTP interface.

Some servers only run a GC every few minutes.
On such servers, the heap profile will be a few minutes stale,
which may be too old to be useful.

Requested by private mail.

LGTM=dvyukov
R=dvyukov
CC=golang-codereviews
https://golang.org/cl/161990043
2014-10-24 10:58:13 -04:00
Brad Fitzpatrick
42c3130780 net/http: don't send implicit gzip Accept-Encoding on Range requests
The http package by default adds "Accept-Encoding: gzip" to outgoing
requests, unless it's a bad idea, or the user requested otherwise.
Only when the http package adds its own implicit Accept-Encoding header
does the http package also transparently un-gzip the response.

If the user requested part of a document (e.g. bytes 40 to 50), it appears
that Github/Varnish send:
        range(gzip(content), 40, 50)

And not:
        gzip(range(content, 40, 50))

The RFC 2616 set of replacements (with the purpose of
clarifying ambiguities since 1999) has an RFC about Range
requests (http://tools.ietf.org/html/rfc7233) but does not
mention the interaction with encodings.

Regardless of whether range(gzip(content)) or gzip(range(content)) is
correct, this change prevents the Go package from asking for gzip
in requests if we're also asking for Range, avoiding the issue.
If the user cared, they can do it themselves. But Go transparently
un-gzipping a fragment of gzip is never useful.

Fixes #8923

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/155420044
2014-10-15 17:51:30 +02:00
Brad Fitzpatrick
9d51cd0fee net/http: don't reuse a server connection after any Write errors
Fixes #8534

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/149340044
2014-10-15 17:51:12 +02:00
Rob Pike
968153d063 net/rpc: fix mutex comment
Fixes #8086.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/153420044
2014-10-13 10:27:51 -07:00
Alex Brainman
c689abd56c net: link skipped TestReadFromUDP to the issue
LGTM=minux
R=bradfitz, minux
CC=golang-codereviews
https://golang.org/cl/154220043
2014-10-10 13:12:32 +11:00
Alex Brainman
eeb2211a5b net: skip new TestReadFromUDP on nacl and plan9 (fixes build)
TBR=0intro
R=golang-codereviews
CC=golang-codereviews
https://golang.org/cl/157820043
2014-10-10 09:46:41 +11:00
Ron Hashimoto
3114bd6f97 net: disable SIO_UDP_CONNRESET behavior on windows.
Fixes #5834.

LGTM=alex.brainman
R=golang-codereviews, bradfitz, alex.brainman, mikioh.mikioh, in60jp, iant
CC=golang-codereviews
https://golang.org/cl/149510043
2014-10-10 09:21:32 +11:00
David du Colombier
9be9861c91 net/rpc: fix build
LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/151620043
2014-10-09 11:21:21 +02:00
David du Colombier
e6295210b9 net/rpc: skip TestGobError on Plan 9
LGTM=bradfitz
R=rsc, bradfitz
CC=aram, golang-codereviews
https://golang.org/cl/154140043
2014-10-09 11:12:03 +02:00
Russ Cox
3492ee5d3a net/rpc: listen on localhost, let kernel pick port
This avoids a pop-up box on OS X and it avoids
a test failure if something is using 5555.
I apologize for not noticing this during the review.

TBR=r
CC=golang-codereviews
https://golang.org/cl/152320044
2014-10-07 23:08:07 -04:00
Rob Pike
6ee36a9151 net/rpc: add test for issue 7689 (gob error should cause EOF)
Helpfully supplied by tommi.virtanen in issue 8173.

LGTM=rsc
R=golang-codereviews, rsc
CC=golang-codereviews
https://golang.org/cl/151370043
2014-10-07 10:52:16 -07:00
Jens Frederich
f739b77508 net/http: fix authentication info leakage in Referer header (potential security risk)
http.Client calls URL.String() to fill in the Referer header, which may
contain authentication info. This patch removes authentication info from
the Referer header without introducing any API changes.

A new test for net/http is also provided.

This is the polished version of Alberto García Hierro's
https://golang.org/cl/9766046/

It should handle https Referer right.

Fixes #8417

LGTM=bradfitz
R=golang-codereviews, gobot, bradfitz, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/151430043
2014-10-07 07:13:42 -07:00
Russ Cox
5b829cca12 net/url: document result of String
Fixes #8742.

LGTM=bradfitz
R=golang-codereviews
CC=adg, bradfitz, golang-codereviews, iant
https://golang.org/cl/155910043
2014-10-06 15:49:07 -04:00
Russ Cox
83001ffaaf net: disable TestDualStackUDPListener in short mode
This test is flaky, just like TestDualStackTCPListener.
That one was disabled. Disable this one too.

Update #5001

LGTM=bradfitz
R=rlh, bradfitz
CC=golang-codereviews
https://golang.org/cl/154950043
2014-10-06 13:09:14 -04:00
Rob Pike
cd5b785efe net/rpc: shut down connection if gob has error
The nicest solution would be to buffer the message and only write
it if it encodes correctly, but that adds considerable memory and
CPU overhead for a very rare condition. Instead, we just shut
down the connection if this happens.
Fixes #7689.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/146670043
2014-10-01 13:18:44 -07:00
Brad Fitzpatrick
4a532c664d net/http/httputil: ensure DumpRequestOut dumps all of Body
Bodies larger than 8KB (the default bufio reader size) weren't
being dumped.  Force a read of the body so they're teed into
the response buffer.

Thanks to Steven Hartland for identifying the problem.

Fixes #8089

LGTM=r
R=golang-codereviews, r
CC=adg, golang-codereviews
https://golang.org/cl/144650044
2014-09-30 12:09:34 -07:00
Brad Fitzpatrick
f13cec9f57 net/http: make Transport.CloseIdleConnections also close pending dials
See comment 4 of https://code.google.com/p/go/issues/detail?id=8483#c4:

"So if a user creates a http.Client, issues a bunch of
requests and then wants to shutdown it and all opened connections;
what is she intended to do? The report suggests that just waiting for
all pending requests and calling CloseIdleConnections won't do, as
there can be new racing connections. Obviously she can't do what
you've done in the test, as it uses the unexported function.  If this
happens periodically, it can lead to serious resource leaks (the
transport is also preserved alive).  Am I missing something?"

This CL tracks the user's intention to close all idle
connections (CloseIdleConnections sets it true; and making a
new request sets it false). If a pending dial finishes and
nobody wants it, before it's retained for a future caller, the
"wantIdle" bool is checked and it's closed if the user has
called CloseIdleConnections without a later call to make a new
request.

Fixes #8483

LGTM=adg
R=golang-codereviews, dvyukov, adg
CC=golang-codereviews, rsc
https://golang.org/cl/148970043
2014-09-29 18:16:15 -07:00
James Tucker
2da734189d net/http: enable Transfer-Encoding: identity without Content-Length for HTTP 1.1.
Use case is SSE recommended configuration: http://www.w3.org/TR/eventsource/#notes
Removes a TODO.

LGTM=bradfitz
R=golang-codereviews, bradfitz, tommi.virtanen
CC=golang-codereviews
https://golang.org/cl/100000044
2014-09-29 13:53:42 -07:00
Brad Fitzpatrick
705c1f5cd4 net/http: clarify Request.FormValue docs
Fixes #8067

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/146480043
2014-09-29 13:42:33 -07:00
Brad Fitzpatrick
dca460574f net: fix misleading package comment example
Fixes #8607

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/146470043
2014-09-29 12:24:06 -07:00
Brad Fitzpatrick
dfaf1f71e6 net/http: update ProxyFromEnvironment docs for HTTPS_PROXY addition
LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/142650043
2014-09-24 17:39:00 -07:00
Nigel Tao
e59ad69a44 net/http: allow double-quotes only on cookie values, not cookie
attribute values, a la RFC 6265 section 4.1.1 "Syntax".

Fixes #7751.

LGTM=dr.volker.dobler
R=dr.volker.dobler
CC=bradfitz, golang-codereviews
https://golang.org/cl/148890043
2014-09-25 10:21:52 +10:00
Brad Fitzpatrick
446524269e net/http: check for CloseWrite interface, not TCPConn implementation
Fixes #8724

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/148040043
2014-09-24 17:01:54 -07:00
Brad Fitzpatrick
e6f21be3f4 net/http: support https_proxy in ProxyFromEnvironment
Fixes #6181

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/148980043
2014-09-24 16:55:39 -07:00
Russ Cox
6077f0fc32 cmd/go: fix bytes and net the right way
Not sure why they used empty.s and all these other
packages were special cased in cmd/go instead.
Add them to the list.

This avoids problems with net .s files being compiled
with gcc in cgo mode and gcc not supporting // comments
on ARM.

Not a problem with bytes, but be consistent.

The last change fixed the ARM build but broke the Windows build.
Maybe *this* will make everyone happy. Sigh.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/144530046
2014-09-24 19:18:01 -04:00
Russ Cox
d2b84dd941 net: only "build" empty.s in non-cgo mode
In cgo mode it gets passed to gcc, and on ARM
it appears that gcc does not support // comments.

TBR=iant
CC=golang-codereviews
https://golang.org/cl/142640043
2014-09-24 19:09:43 -04:00
Russ Cox
a0785a53ad cmd/go: prohibit C sources files unless using cgo
Those C files would have been compiled with 6c.
It's close to impossible to use C correctly anymore,
and the C compilers are going away eventually.
Make them unavailable now.

go1.4.txt change in CL 145890046

LGTM=iant
R=iant
CC=golang-codereviews, r
https://golang.org/cl/149720043
2014-09-24 15:10:38 -04:00
Brad Fitzpatrick
93e5cc224e net/http: replace z_last_test hack with testing.Main
LGTM=adg
R=rsc, adg
CC=golang-codereviews
https://golang.org/cl/144240043
2014-09-22 09:13:09 -04:00
Russ Cox
2c15d45131 net/http: document server recovering panics
Fixes #8594.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/145760043
2014-09-19 13:53:33 -04:00
John Tuley
0c47bd1e61 net/http: ensured that proxy errors are returned by Transport.RoundTrip.
Fixes #8755.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, jtuley
https://golang.org/cl/136710044
2014-09-19 11:28:38 -04:00
Russ Cox
76c7548162 net: disable TestDialMultiFDLeak
It fails about 25% of the time on OS X.
I don't know what it's trying to do.
Created issue 8764 to correct this, but for now disable.

LGTM=bradfitz, mikioh.mikioh
R=bradfitz, mikioh.mikioh
CC=golang-codereviews
https://golang.org/cl/144070044
2014-09-18 14:48:26 -04:00
Mikio Hara
484cc67151 net: separate NaCl dependent placeholders from BSD's
To clarify the dependency of NaCl platform.

LGTM=adg
R=golang-codereviews, adg
CC=golang-codereviews
https://golang.org/cl/143830044
2014-09-18 19:17:55 +09:00
Russ Cox
06e4b06893 net/mail: allow us-ascii encoding
Fixes #6611.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews
https://golang.org/cl/14990045
2014-09-16 17:40:33 -04:00
Russ Cox
95c899f03c net: make TestSelfConnect less fragile
We believe TestSelfConnect can accidentally connect to
something else listening on or dialing from that port.

Fixes #8680.

LGTM=bradfitz
R=bradfitz
CC=golang-codereviews, rlh
https://golang.org/cl/136700043
2014-09-16 14:02:59 -04:00
Brad Fitzpatrick
bb431245cc net/http: don't call FileSystem.Open with unclean index.html path
Fixes #8722

LGTM=adg
R=adg
CC=golang-codereviews
https://golang.org/cl/142090043
2014-09-15 07:14:33 -04:00
Mikio Hara
f956740163 net: fix inconsistent behavior across platforms in SetKeepAlivePeriod
The previous implementation used per-socket TCP keepalive options
wrong. For example, it used another level socket option to control
TCP and it didn't use TCP_KEEPINTVL option when possible.

Fixes #8683.
Fixes #8701.
Update #8679

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/136480043
2014-09-11 17:56:58 +09:00
Mikio Hara
1fadd9e1ae net: don't set wrong option for controlling tcp keepalive on openbsd
Fixes #8679.

LGTM=iant
R=golang-codereviews, iant
CC=golang-codereviews
https://golang.org/cl/141730043
2014-09-09 07:22:11 +09:00
Russ Cox
c007ce824d build: move package sources from src/pkg to src
Preparation was in CL 134570043.
This CL contains only the effect of 'hg mv src/pkg/* src'.
For more about the move, see golang.org/s/go14nopkg.
2014-09-08 00:08:51 -04:00