summaryrefslogtreecommitdiff
path: root/src/net/http
Commit message (Collapse)AuthorAgeFilesLines
* net/http: document that after Hijack, Request.Body is invalidBrad Fitzpatrick2017-07-211-0/+3
| | | | | | | | | | | | | We can make it panic with a more explicit and readable error message during Go 1.10, but document it for now. This has always been the case; it's not a new rule. Updates #20933 Change-Id: I53c1fefb47a8f4aae0bb32fa742afa3a2ed20e8a Reviewed-on: https://go-review.googlesource.com/50634 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
* net/http: improve signature of Redirect, NewRequestDmitri Shuralyov2017-07-202-16/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In CL https://golang.org/cl/4893043 (6 years ago), a new package named "url" was created (it is currently known as "net/url"). During that change, some identifier name collisions were introduced, and two parameters in net/http were renamed to "urlStr". Since that time, Go has continued to put high emphasis on the quality and readability of the documentation. Sometimes, that means making small sacrifices in the implementation details of a package to ensure that the godoc reads better, since that's what the majority of users interact with. See https://golang.org/s/style#named-result-parameters: > Clarity of docs is always more important than saving a line or two > in your function. I think the "urlStr" parameter name is suboptimal for godoc purposes, and just "url" would be better. During the review of https://golang.org/cl/4893043, it was also noted by @rsc that having to rename parameters named "url" was suboptimal: > It's unfortunate that naming the package url means > you can't have a parameter or variable named url. However, at the time, the name of the url package was still being decided, and uri was an alternative name under consideration. The reason urlStr was chosen is because it was a lesser evil compared to naming the url package uri instead: > Let's not get hung up on URI vs. URL, but I'd like s/uri/urlStr/ even for just > that the "i" in "uri" looks very similar to the "l" in "url" in many fonts. > Please let's go with urlStr instead of uri. Now that we have the Go 1 compatibility guarantee, the name of the net/url package is fixed. However, it's possible to improve the signature of Redirect, NewRequest functions in net/http package for godoc purposes by creating a package global alias to url.Parse, and renaming urlStr parameter to url in the exported funcs. This CL does so. Updates #21077. Change-Id: Ibcc10e3825863a663e6ad91b6eb47b1862a299a6 Reviewed-on: https://go-review.googlesource.com/49930 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: fix parameter name in commentIan Lance Taylor2017-07-181-1/+1
| | | | | | | | Fixes #21077 Change-Id: Ic61d7313907f58ff4027fd2eee1ddb8c1656304d Reviewed-on: https://go-review.googlesource.com/49712 Reviewed-by: Dmitri Shuralyov <shurcool@gmail.com>
* net/http: clarify Handler panic behavior across HTTP versionsBrad Fitzpatrick2017-07-141-3/+4
| | | | | | | | | Updates #18997 Change-Id: Ib1961a4c26b42f99b98b255beb7e2a74b632e0c1 Reviewed-on: https://go-review.googlesource.com/48551 Reviewed-by: Joe Shaw <joe@joeshaw.org> Reviewed-by: Tom Bergan <tombergan@google.com>
* net/http/httptest: allow creation of Server manuallyJoe Tsai2017-06-302-16/+59
| | | | | | | | | | | | | | | | | | | | | | The Server struct has exported fields, which allows users to manually create a Server object without using using NewServer or NewTLSServer and directly call Start or StartTLS on their object. In order to ensure that manual creation of Server works, the NewUnstartedServer function should not initialize Server in any way that the user was not able to do themselves. For example, the setting of a unexported filed, client, is not something a user can do. Thus, rather than setting the client field in NewUnstartedServer, we lazily initialize it when Start or StartTLS is called. Otherwise, the Server logic can nil panic later when it assumes that this field has been initialized. Fixes #20871 Change-Id: I65c6a9f893ea963b0fbad0990b33af08007c1140 Reviewed-on: https://go-review.googlesource.com/47353 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: update bundled http2Brad Fitzpatrick2017-06-291-6/+17
| | | | | | | | | | | | | | | Updates http2 to x/net/http2 git rev d4223d6710a for: http2: refund connection flow control on DATA frames received after reset https://golang.org/cl/46591 Fixes #46591 Change-Id: I5e6999599e921fed279c6d29ae77439191e99615 Reviewed-on: https://go-review.googlesource.com/47096 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tom Bergan <tombergan@google.com>
* net/http: whitelist another non-http goroutine in leak checkerBrad Fitzpatrick2017-06-271-0/+1
| | | | | | | | | | | Fixes #20810 Change-Id: I09365b2db50c41aa3383dd730859b6f2cdb78e63 Reviewed-on: https://go-review.googlesource.com/46836 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/pprof: mention mutex profile in docHana (Hyang-Ah) Kim2017-06-261-0/+5
| | | | | | | | | | | mutex profile requires explicit calls to runtime.SetMutexProfileFraction to enable/disable profiling (like block profile). It is worth mentioning in the doc. Change-Id: I2b8d654be9f5c6bc49fc802b7708c4c552fea9b2 Reviewed-on: https://go-review.googlesource.com/42070 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: fix double-close of req.BodyMatt Harden2017-06-262-5/+38
| | | | | | | | | | | | | Add a test and fix for the request body being closed twice. Fixes #19186 Change-Id: I1e35ad4aebfef68e6099c1dba7986883afdef4d7 Reviewed-on: https://go-review.googlesource.com/37298 Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/httputil: always deep copy the Request.Header map in ReverseProxyBrad Fitzpatrick2017-06-262-14/+45
| | | | | | | | | | | | | | We used to do it sometimes as an optimization, but the optimization is flawed: in all non-contrived cases we need to deep clone the map anyway. So do it always, which both simplifies the code but also fixes the X-Forward-For value leaking to the caller's Request, as well as modifications from the optional Director func. Fixes #18327 Change-Id: I0c86d10c557254bf99fdd988227dcb15f968770b Reviewed-on: https://go-review.googlesource.com/46716 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net/http/httptest: close client connections in separate goroutinesYasha Bubnov2017-06-261-1/+1
| | | | | | | | | | | | | | The existing implementation sequentially closes connection in the loop and until the previous client connections is not closed the next one would not be processed. Instead, the algorithm modified to spawn the function that closes single connection in a standalone goroutine, thus making at least a try to close it. Change-Id: Ib96b5b477f841926450d122b67f14f1a2da36ee1 Reviewed-on: https://go-review.googlesource.com/33614 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: document that Dir can serve sensitive directoriesKevin Burke2017-06-231-0/+6
| | | | | | | | Updates #20759. Change-Id: Ic61dcb6d101ad1491dca535aebb6ee8ee740d013 Reviewed-on: https://go-review.googlesource.com/46468 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: Update server idleTimeout documentationQiuxuan Zhu2017-06-231-1/+1
| | | | | | | | Fixes #20383 Change-Id: I11234393c3beb669f87976a4f0b424bec7372b82 Reviewed-on: https://go-review.googlesource.com/46434 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: update bundled http2Brad Fitzpatrick2017-06-191-2/+17
| | | | | | | | | | | | | | | | Updates http2 to x/net/http2 git rev 3d7ac2a5d for: http2: fix Server race https://golang.org/cl/20704 Fixes #20704 Change-Id: I803288f94a8a462ad0960b0c29c2dfee27b9f1ae Reviewed-on: https://go-review.googlesource.com/46093 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Tom Bergan <tombergan@google.com> Reviewed-by: Tom Bergan <tombergan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: update bundled http2Brad Fitzpatrick2017-06-161-2/+4
| | | | | | | | | | | | | | | Updates http2 to x/net/http2 git rev 973f3f3 for: http2: make Transport treat http.NoBody like it were nil https://golang.org/cl/45993 Updates #18891 Change-Id: I846ccf286992ed2c6249014e51fdeb40b35e50ed Reviewed-on: https://go-review.googlesource.com/46000 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: add a known goroutine, don't check goroutine leaks in benchmark modeBrad Fitzpatrick2017-06-151-2/+16
| | | | | | Change-Id: I8aa070f8093e80ba19f0546d7447caf847a2b388 Reviewed-on: https://go-review.googlesource.com/45912 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net/http: document SOCKS5 proxy supportKale Blankenship2017-06-151-0/+5
| | | | | | | | Fixes #20618 Change-Id: I90712bd76d9d47f29221bc298c69737ebee25c12 Reviewed-on: https://go-review.googlesource.com/45814 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: update bundled http2Brad Fitzpatrick2017-06-141-7/+19
| | | | | | | | | | | | | | | | | | Update x/net/http2 to git rev 6b17b9baf5 for: http2: stop rejecting outgoing paths beginning with two slashes https://golang.org/cl/45773 This also uses an updated version of x/tools/cmd/bundle (CL 45190) that fixes an edge case where it used to drop some comments. Updates #20627 Fixes #19103 Change-Id: I450d61485e66098f4f8a79954f729f7bcd85856f Reviewed-on: https://go-review.googlesource.com/45700 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Chris Broadfoot <cbro@golang.org>
* net/http: fix application/ogg sniff signatureEmmanuel Odeke2017-06-132-2/+6
| | | | | | | | | | | | | | | | | | | I accidentally set the wrong pattern mask as * []byte("\x4F\x67\x67\x53\x00") --> "OggS", the byte pattern itself. instead of * []byte("\xFF\xFF\xFF\xFF\xFF") which was a copy-paste error. The correct pattern is described at https://mimesniff.spec.whatwg.org/#matching-an-audio-or-video-type-pattern which I was using as a reference but I mistyped. Fixes #20513 Change-Id: Ie9cb60ac7edbf03075070878775b964116ce92d0 Reviewed-on: https://go-review.googlesource.com/44336 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
* net/http: regenerate http2 bundle with bundle fixes to include commentsBrad Fitzpatrick2017-06-091-238/+711
| | | | | | | | | | | | | | | | The golang.org/x/tools/cmd/bundle tool previously had a bug where it dropped some comments. This regenerates it with the fixed version (https://golang.org/cl/45117). (Upstream is still git rev 3470a06c1, from https://golang.org/cl/44331) Updates #20548 Change-Id: Ic5d9208a0c8f7facdb7b315c6acab66ace34c0a9 Reviewed-on: https://go-review.googlesource.com/45158 Reviewed-by: Hiroshi Ioka <hirochachacha@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: remove invalid checks of Request.Proto* for outgoing requestsBrad Fitzpatrick2017-06-082-14/+2
| | | | | | | | | | | | | | | | The net/http package has long documented that Request.ProtoMajor and Request.ProtoMinor are ignored for outgoing requests (HTTP/1.1 or HTTP/2 is always used, never HTTP/1.0). There was one part in the code that was actually checking 1.0 vs 1.1, but it appears to have been harmless. Remove it. Fixes #18407 Change-Id: I362ed6c47ca2de7a2fbca917ed3e866273cfe41f Reviewed-on: https://go-review.googlesource.com/45155 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net/http: simplify recently added TestServeTLSBrad Fitzpatrick2017-06-081-34/+24
| | | | | | | | | | | | | TestServeTLS was added in CL 44074, merged today. This cleans up the test a little. Updates #13228 Change-Id: I6efd798fe5fa015a34addbf60ae26919a1ed283e Reviewed-on: https://go-review.googlesource.com/45152 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net/http: add Server.ServeTLS methodNiklas Schnelle2017-06-082-28/+127
| | | | | | | | | | | | | | | | | | | | | Server.ServeTLS wraps Server.Serve with added TLS support. This is particularly useful for serving on manually initialized listeners. Example use-case includes ability to serve with TLS on listener provided by systemd's socket activation. A matching test heavily based on TestAutomaticHTTP2_ListenAndServe is also included. Original code by Gurpartap Singh as https://go-review.googlesource.com/c/38114/ Fixes #13228 Change-Id: I73bb703f501574a84d261c2d7b9243a89fa52d62 Reviewed-on: https://go-review.googlesource.com/44074 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: enable TestLinuxSendfile on mips64Vladimir Stefanovic2017-06-081-3/+1
| | | | | | | | | | The test is passing on a 64bit RFS. Fixes #18008 Change-Id: Ia4c4f4dde0392c7f6bbe5dbffc97cf848ec5a107 Reviewed-on: https://go-review.googlesource.com/44953 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: delete vestigial methodBrad Fitzpatrick2017-06-071-5/+0
| | | | | | | | | | Fixes #19850 Change-Id: I8c86e288159408c687c2a85f458ade282adae450 Reviewed-on: https://go-review.googlesource.com/45077 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* net/http: don't crash in Request.WithContext if Request.URL is nilBrad Fitzpatrick2017-06-072-3/+12
| | | | | | | | | | | | Fixes #20601 Change-Id: I296d50dc5210a735a2a65d64bfef05d14c93057b Reviewed-on: https://go-review.googlesource.com/45073 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Rhys Hiltner <rhys@justin.tv> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: make Transport retry GetBody requests if nothing writtenDavid Glasser2017-06-056-82/+186
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is another attempt at the change attempted in https://golang.org/cl/27117 and rolled back in https://golang.org/cl/34134 The difference between this and the previous attempt is that this version only retries if the new field GetBody is set on the Request. Additionally, this allows retries of requests with idempotent methods even if they have bodies, as long as GetBody is defined. This also fixes an existing bug where readLoop could make a redundant call to setReqCanceler for DELETE/POST/PUT/etc requests with no body with zero bytes written. This clarifies the existing TestRetryIdempotentRequestsOnError test (and changes it into a test with 4 subtests). When that test was written, it was in fact testing "retry idempotent requests" logic, but the logic had changed since then, and it was actually testing "retry requests with no body when no bytes have been written". (You can confirm this by changing the existing test from a GET to a DELETE; it passes without the changes in this CL.) We now test for the no-Body and GetBody cases for both idempotent and nothing-written-non-idempotent requests. Fixes #18241 Fixes #17844 Change-Id: I69a48691796f6dc08c31f7aa7887b7dfd67e278a Reviewed-on: https://go-review.googlesource.com/42142 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: update bundled x/net/http2Tom Bergan2017-05-261-3/+3
| | | | | | | | | | | | | | | | | | This updates the bundled copy of x/net/http2 to x/net git rev 3470a06c1357df53 for: http2: fix typo in comment https://golang.org/cl/44271 http2: fix nil dereference after Read completes with an error https://golang.org/cl/44330 Fixes #20501 Change-Id: Ie6a5fb092f77044f504f146721dae86299e04011 Reviewed-on: https://go-review.googlesource.com/44331 Run-TryBot: Tom Bergan <tombergan@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: revert CL 43779Emmanuel Odeke2017-05-252-51/+0
| | | | | | | | | | | | | CL 43779/commit 6a6c792eef55eded7fb3165a330ec2b239b83960 broke the builds at tip, and that CL doesn't account for cases where Redirect is directly invoked with a full URL that itself has a query string. Updates #17841 Change-Id: Idb0486bae8625e1f9e033ca4cfcd87de95bc835c Reviewed-on: https://go-review.googlesource.com/44100 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: Don't write 'Connection: close' header multiple times.Filip Gruszczyński2017-05-242-1/+30
| | | | | | | | | | | | | | | When writing the 'Connection: close' header based on response Close attribute we also check if it is already in the headers scheduled to be written and skip if necessary. Fixes #19499 Change-Id: I92357344a37ae385454ec8006114fa4cfa585810 Reviewed-on: https://go-review.googlesource.com/38076 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: deep copy Request.URL also in Request.WithContext's copyEmmanuel Odeke2017-05-243-0/+62
| | | | | | | | | | | | | | Despite the previously known behavior of Request.WithContext shallow copying a request, usage of the request inside server.ServeHTTP mutates the request's URL. This CL implements deep copying of the URL. Fixes #20068 Change-Id: I86857d7259e23ac624d196401bf12dde401c42af Reviewed-on: https://go-review.googlesource.com/41308 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: permit incoming CONNECT requests without Host headersBrad Fitzpatrick2017-05-242-1/+4
| | | | | | | | | | | | | | | Apparently they exist in the wild. See: https://github.com/golang/go/issues/18215#issuecomment-301182496 (Facebook / iOS) Fixes #18215 Change-Id: I9ddad3896b5d784cb3f5b3ee9c6819081a4a2702 Reviewed-on: https://go-review.googlesource.com/44004 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Matt Layher <mdlayher@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: polish gzip case insensitive testEmmanuel Odeke2017-05-241-5/+5
| | | | | | | | | | | | Avoid directly using the binary of the gzipped encoded string in the handler. Follow up of CL 37431. Change-Id: Idcd04acb7940e67b7a35b2d6cb163d75b0e22e04 Reviewed-on: https://go-review.googlesource.com/44008 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: make Transport respect non lower case Content-EncodingJan Berktold2017-05-242-1/+35
| | | | | | | | | | | | | | | The existing Transport implementation does not detect gzip encoding when the Content-Encoding header is not lower-case. This is not compliant with RFC2616 section 3.5 "All content-coding values are case-insensitive." and caused issues in the wild. Fixes #19248 Change-Id: I1b49992832dc3c8ef700058596a27dd9909640a3 Reviewed-on: https://go-review.googlesource.com/37431 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: update bundled x/net/http2Brad Fitzpatrick2017-05-241-80/+157
| | | | | | | | | | | | | | | | | | This updates the bundled copy of x/net/http2 to x/net git rev a8e8f92cd6 for: http2: remove extra goroutine stack from awaitGracefulShutdown https://golang.org/cl/43230 http2: Discard DATA frames from the server after the response body is closed https://golang.org/cl/43810 Fixes #20302 Fixes #18471 Fixes #20448 Change-Id: I00972836deb2fe6049f631ee44901732a641b171 Reviewed-on: https://go-review.googlesource.com/44006 Reviewed-by: Tom Bergan <tombergan@google.com>
* net/http: Add Server.RegisterOnShutdownTom Bergan2017-05-232-2/+26
| | | | | | | | | | | | | | | | | This will be used to allow http2 servers to register a shutdown function so that net/http.Server.Shutdown will work when the http2 server is configured via a manual call to http2.ConfigureServer. Currently, Shutdown only works when the http2 server is configured automatically by the net/http package. Updates #20302 Updates #18471 Change-Id: Ifc2b5f3126126a106b49ea4a7e999279852b9cc9 Reviewed-on: https://go-review.googlesource.com/44003 Run-TryBot: Tom Bergan <tombergan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http/httptest: make ResponseRecorder.Result.Status match http.TransportBrad Fitzpatrick2017-05-232-3/+13
| | | | | | | | | | Fixes #18438 Change-Id: I9599c1536d5e8bad7662b8ffa19e9b0746e27e60 Reviewed-on: https://go-review.googlesource.com/44000 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/cookiejar: increase test coverageVolker Dobler2017-05-222-0/+14
| | | | | | | | | | | The jarKey function handles broken PublicSuffixList implementations but no test verified it. Change-Id: Ifb76de9e8c3941f3b08d3e43970056e023013457 Reviewed-on: https://go-review.googlesource.com/38357 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: send more cookie values in double quotesVolker Dobler2017-05-222-4/+7
| | | | | | | | | | | | | | | | | | | | | | | According to RFC 6255 a cookie value may contain neither spaces " " nor commas ",". But browsers seem to handle these pretty well and such values are not uncommon in the wild so we do allow spaces and commas in cookie values too. Up to now we use the double-quoted wire format only for cookie values with leading and/or trailing spaces and commas. Values with internal spaces/commas are sent without the optional double quotes. This seems to be a problem for some agents. This CL changes the behaviour for cookie values with spaces or commas: Such values are always sent in double quotes. This should not have any impact on existing agents and the increases of data transmitted is negligible. Fixes #18627 Change-Id: I575a98d589e048aa39d976a3c984550daaca730a Reviewed-on: https://go-review.googlesource.com/37328 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http/httputil: ReverseProxy should pass on unannounced TrailersTristan Colgate2017-05-222-2/+18
| | | | | | | | | | | | | | | | | Trailers that are not announced in the Trailer must be passed on to the downstream client. Rather than iterate over each and find missing trailer values, this re-adds all trailers to the headers if there is a disparity between the number of announced trailers and the final number. This fixes #20437 Change-Id: I867e85f45feff68616a9a9bd6f65f12d73825eb7 Reviewed-on: https://go-review.googlesource.com/43712 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: make ServeMux preserve query string during redirectsEmmanuel Odeke2017-05-222-0/+51
| | | | | | | | | | | | | | | | | Ensure that the implicitly created redirect for "/route" after "/route/" has been registered doesn't lose the query string information. Fixes #17841. Change-Id: Ib7df9242fab8c9368a18fc0da678003d6bec63b8 Reviewed-on: https://go-review.googlesource.com/43779 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: for http2, use the priority write scheduler by defaultTom Bergan2017-05-111-1/+4
| | | | | | | | | | Updates #18318 Change-Id: Ibd4ebc7708abf87eded8da9661378b5777b8a400 Reviewed-on: https://go-review.googlesource.com/43231 Run-TryBot: Tom Bergan <tombergan@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: update bundled http2Brad Fitzpatrick2017-05-031-23/+633
| | | | | | | | | | | | | | | | Updates bundled http2 to x/net/http2 git rev feeb485 for: http2: add all bad ciphers, use package constants https://golang.org/cl/42510 Updates #20213 Change-Id: I851453e3785e6b126db7a5c5eec2ebbbf61358ae Reviewed-on: https://go-review.googlesource.com/42494 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Savintsev <dsavints@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: bgErr is unused; remove itChris Manghane2017-05-021-6/+0
| | | | | | | | Fixes #20196. Change-Id: Ib87f6e9e27a38f21f860b7150c818d77be653dd3 Reviewed-on: https://go-review.googlesource.com/42370 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: enable TestRequestDoesntBodyCloseDoesntBlockEmmanuel Odeke2017-04-291-1/+1
| | | | | | | | | | | | | Fixes #7121. CL 31173 inadvertently fixed this issue in the Go1.8 cycle. This CL enables the test for that issue. Change-Id: I8e73b41f646fa89c75bff833c1b07e1cdb2b1e62 Reviewed-on: https://go-review.googlesource.com/42149 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http: re-simplify HTTP/1.x status line writingBrad Fitzpatrick2017-04-283-58/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It used to be simple, and then it got complicated for speed (to reduce allocations, mostly), but that involved a mutex and hurt multi-core performance, contending on the mutex. A change was sent to try to improve that mutex contention in https://go-review.googlesource.com/c/42110/2/src/net/http/server.go but that introduced its own allocations (the string->interface{} boxing for the sync.Map key), which runs counter to the whole point of that statusLine function: to remove allocations. Instead, make the code simple again and not have a mutex. It's a bit slower for the single-core case, but nobody with a single-user HTTP server cares about 50 nanoseconds: name old time/op new time/op delta ResponseStatusLine 37.5ns ± 2% 87.1ns ± 2% +132.42% (p=0.029 n=4+4) ResponseStatusLine-2 63.1ns ± 1% 43.1ns ±12% -31.67% (p=0.029 n=4+4) ResponseStatusLine-4 53.8ns ± 8% 40.2ns ± 2% -25.29% (p=0.029 n=4+4) name old alloc/op new alloc/op delta ResponseStatusLine 0.00B ±NaN% 0.00B ±NaN% ~ (all samples are equal) ResponseStatusLine-2 0.00B ±NaN% 0.00B ±NaN% ~ (all samples are equal) ResponseStatusLine-4 0.00B ±NaN% 0.00B ±NaN% ~ (all samples are equal) name old allocs/op new allocs/op delta ResponseStatusLine 0.00 ±NaN% 0.00 ±NaN% ~ (all samples are equal) ResponseStatusLine-2 0.00 ±NaN% 0.00 ±NaN% ~ (all samples are equal) ResponseStatusLine-4 0.00 ±NaN% 0.00 ±NaN% ~ (all samples are equal) (Note the code could be even simpler with fmt.Fprintf, but that is relatively slow and involves a bunch of allocations getting arguments into interface{} for the call) Change-Id: I1fa119132dbbf97a8e7204ce3e0707d433060da2 Reviewed-on: https://go-review.googlesource.com/42133 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
* net/http: close resp.Body when error occurred during redirectionWeichao Tang2017-04-272-0/+9
| | | | | | | | | | Fixes #19976 Change-Id: I48486467066784a9dcc24357ec94a1be85265a6f Reviewed-on: https://go-review.googlesource.com/40940 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: make LocalAddrContext handle wildcard interfaceMichael Fraenkel2017-04-262-8/+32
| | | | | | | | | | | | | The LocalAddrContext should have the network address of the actual interface. Fixes #18686 Change-Id: I9c401eda312f3a0e7e65b013af827aeeef3b4d3d Reviewed-on: https://go-review.googlesource.com/35490 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* net/http: update bundled x/net/http2Brad Fitzpatrick2017-04-252-8/+28
| | | | | | | | | | | | | | | | | | | | | This updates the bundled http2 package from git rev 5602c733f70afc6dcec6766be0d5034d4c4f14de of the x/net repo for: http2: Use NO_ERROR instead of CANCEL when responding before the request is finished https://golang.org/cl/40630 http2: enforce write deadline per stream https://golang.org/cl/34727 Updates golang/go#19948 Fixes golang/go#18437 Change-Id: I14500476e91551fa8f27a1aeb8ae3cac9600b74c Reviewed-on: https://go-review.googlesource.com/41753 Reviewed-by: Kale Blankenship <kale@lemnisys.com> Reviewed-by: Tom Bergan <tombergan@google.com> Run-TryBot: Kale Blankenship <kale@lemnisys.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
* net/http/cgi: fix plan9 buildBrad Fitzpatrick2017-04-251-1/+0
| | | | | | | | | | | Cleanup CL https://golang.org/cl/41691 broke the plan9 build by removing a use of a package but not removing the package import. Trybots don't check that. I filed #20119 for that. Change-Id: Ia030e6924665dfb871ca964455b899d51b0200c2 Reviewed-on: https://go-review.googlesource.com/41752 Reviewed-by: David du Colombier <0intro@gmail.com>