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

371 Commits

Author SHA1 Message Date
Rob Pike
7d43b84282 time: make Weekday a method.
Weekday is redundant information for a Time structure.
When parsing a time with a weekday specified, it can create an
incorrect Time value.
When parsing a time without a weekday specified, people
expect the weekday to be set.
Fix all three problems by computing the weekday on demand.

This is hard to gofix, since we must change the type of the node.
Since uses are rare and existing code will be caught by the compiler,
there is no gofix module here.

Fixes #2245.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4974077
2011-09-12 11:47:55 -07:00
Robert Griesemer
61650b21d6 cleanup: gofmt -s -w src misc
R=r
CC=golang-dev
https://golang.org/cl/4984052
2011-09-06 16:04:55 -07:00
Russ Cox
686181edfe url: handle ; in ParseQuery
Most web frameworks allow ; as a synonym for &,
following a recommendation in some versions of
the HTML specification.  Do the same.

Remove overuse of Split.

Move ParseQuery tests from package http to package url.

Fixes #2210.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4973062
2011-09-06 12:24:24 -04:00
Brad Fitzpatrick
7349d21f8e http: add file protocol transport
Off by default (security risk), but users can
wire it up if desired.

Fixes #2113

R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4959049
2011-08-30 21:47:41 -07:00
Brad Fitzpatrick
822804c600 http: support setting Transport's TLS client config
R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4964043
2011-08-26 10:06:35 +04:00
Dave Cheney
8511ed454a http: return 413 instead of 400 when the request body is too large
RFC2616 says servers should return this status code when
rejecting requests that are too large.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.4.14

R=bradfitz
CC=golang-dev
https://golang.org/cl/4962041
2011-08-25 14:00:00 +04:00
Brad Fitzpatrick
fa6d038e98 http: adjust test threshold for larger suse buffers
My theory is that suse has larger TCP buffer sizes
by default.  I now check over 100MB, rather than over 2MB.
100MB is ~halfway between the 1MB limit and the 200MB
request that's attempted.

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4926048
2011-08-24 16:09:49 +04:00
Brad Fitzpatrick
bb4cf3f351 http: on invalid request, send 400 response
Fixes #2160

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4930049
2011-08-24 13:10:22 +04:00
Russ Cox
03582b3308 http: delete error kludge
The kludge is targeted at broken web browsers
like Chrome and IE, but it gets in the way of
sending 400 or 500-series error results with
formatted bodies in response to AJAX requests
made by pages executing in those browsers.

Now the AJAX cases will work and Chrome
and IE will be as broken with Go servers as
they are with all the other servers.

Fixes #2169.

R=bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/4930047
2011-08-23 22:39:25 -04:00
Brad Fitzpatrick
f0ef4f4746 http: add MaxBytesReader to limit request body size
This adds http.MaxBytesReader, similar to io.LimitReader,
but specific to http, and for preventing a class of DoS
attacks.

This also makes the 10MB ParseForm limit optional (if
not already set by a MaxBytesReader), documents it,
and also adds "PUT" as a valid verb for parsing forms
in the request body.

Improves issue 2093 (DoS protection)
Fixes #2165 (PUT form parsing)

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4921049
2011-08-23 12:17:21 +04:00
Brad Fitzpatrick
a986d98053 mime: ParseMediaType returns os.Error now, not a nil map
ParseMediaType previously documented that it always returned
a non-nil map, but also documented that it returned a nil map
to signal an error.

That is confusing, contradictory and not Go-like.

Now it returns (mediatype string, params map, os.Error).

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4867054
2011-08-18 12:51:23 -07:00
Rob Pike
8380ff34ed http: remove a TODO due to new behavior of nil maps
R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/4907049
2011-08-18 11:01:43 +10:00
Rob Pike
1d8f822c17 url: new package
This is just moving the URL code from package http into its own package,
which has been planned for a while.
Besides clarity, this also breaks a nascent dependency cycle the new template
package was about to introduce.

Add a gofix module, url, and use it to generate changes outside http and url.

Sadness about the churn, gladness about some of the naming improvements.

R=dsymonds, bradfitz, rsc, gustavo, r
CC=golang-dev
https://golang.org/cl/4893043
2011-08-17 13:36:02 +10:00
Dave Grijalva
8f3c7497ac http: corrects undocumented side effects in http.DefaultTransport's RoundTrip method
Fixes #2140.

The http.DefaultTransport's RoundTrip method leaves the http.Request object
in an altered state after performing the round trip.  This patch removes
the header from the Request before returning to the client.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4857041
2011-08-10 14:16:13 -07:00
Brad Fitzpatrick
31fa584906 http: fix ParseMultipartForm after MultipartReader error
Addresses part of issue 2093
Thanks to espians....@

R=golang-dev, nigeltao
CC=golang-dev
https://golang.org/cl/4808087
2011-08-10 08:08:53 -07:00
Brad Fitzpatrick
d24a9785eb http: configurable and default request header size limit
This addresses the biggest DoS in issue 2093

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4841050
2011-08-09 10:55:14 -07:00
Yasuhiro Matsumoto
29df7bb7ec http: add test to serve content in index.html
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4798071
2011-08-09 10:25:53 -07:00
Yasuhiro Matsumoto
62d4b8ebd2 http: correct path to serve index.html.
calling filepath.FromSlash(x) make invalid character to serve file.
Fixes #2128

R=golang-dev, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4810064
2011-08-04 08:20:53 -04:00
David Symonds
4143491c4a http: add more MPEG-4 MIME types to sniffer, and disable MP4 sniffing.
R=rsc
CC=golang-dev
https://golang.org/cl/4808056
2011-08-04 22:10:17 +10:00
Alex Brainman
8800f7cb55 http: correct format flags when printing errors during tests
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4809065
2011-08-01 11:50:50 +10:00
Andrew Balholm
3de6228aea http: make serveFile redirects relative to work with StripPrefix
serveFile was using absolute redirects, which didn't work under StripPrefix.
Now it uses relative redirects.

R=golang-dev, rsc, bradfitz
CC=golang-dev, kevlar
https://golang.org/cl/4789042
2011-07-28 11:43:16 -07:00
John Asmuth
2f4632febc container/vector: removed some uses of container/vector in other pkgs
R=gri
CC=golang-dev
https://golang.org/cl/4823054
2011-07-27 15:23:42 -07:00
Robert Griesemer
e21f69338b http: set content type for fileserver directory listings
R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4815062
2011-07-26 11:30:11 -07:00
David Symonds
e527d49e55 http: implement MP4 sniffing.
R=rsc
CC=golang-dev
https://golang.org/cl/4809044
2011-07-26 13:28:20 +10:00
Rob Pike
54045e6bcd pkg/http: fix a couple of error messages
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4805048
2011-07-22 17:11:44 +10:00
David Symonds
99e5d48e59 http: clarify use of w.conn.body in Write when sniffing.
R=gri, r, r, rsc
CC=golang-dev
https://golang.org/cl/4794047
2011-07-22 13:52:21 +10:00
Russ Cox
301d8a6d4a http: fix chunking bug during content sniffing
R=golang-dev, bradfitz, gri
CC=golang-dev
https://golang.org/cl/4807044
2011-07-21 14:29:14 -04:00
Russ Cox
17d9093bf2 undo CL 4808044 / 1bd754e69ce7
ServeMux depends on having a URL
in order to mux.  It might be that the right
fix is to have CONNECT handlers just not
look at URL.

««« original CL description
http: do not parse req.URL for CONNECT

CONNECT's argument is not a URL.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4808044

»»»

TBR=bradfitz
CC=golang-dev
https://golang.org/cl/4798046
2011-07-21 13:25:55 -04:00
Yasuhiro Matsumoto
bf5ec12dd5 http: do not parse req.URL for CONNECT
CONNECT's argument is not a URL.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4808044
2011-07-21 11:33:59 -04:00
David Symonds
6c46afdf41 http: disable sniffer for now.
Something is broken, and investigation is underway.
In the meantime, godoc is broken, so disable sniffing for now
by reverting to the pre-sniffer state.

R=r
CC=golang-dev
https://golang.org/cl/4809046
2011-07-21 22:20:09 +10:00
David Symonds
78c89d21bc http: sniffing algorithm.
This follows draft-ietf-websec-mime-sniff-03 in its intent,
though not its algorithmic specification.

R=rsc
CC=golang-dev
https://golang.org/cl/4746042
2011-07-21 08:38:35 +10:00
Brad Fitzpatrick
3745716bc3 http: let FileServer work when path doesn't begin with a slash
... as when it's over-stripped with StripPrefix.

R=golang-dev, andybalholm, rsc
CC=golang-dev
https://golang.org/cl/4759052
2011-07-18 09:04:48 -07:00
David Symonds
a8e0035bd3 http: drain the pipe output in TestHandlerPanic to avoid logging deadlock.
R=r
CC=golang-dev
https://golang.org/cl/4756047
2011-07-18 12:59:16 +10:00
Brad Fitzpatrick
8b33c7b5be http: make tests quiet, fixing a test race
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4754044
2011-07-17 15:46:10 -07:00
Russ Cox
e07c6e6ee7 http: fixes for sniffing
R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4753044
2011-07-15 12:07:37 -04:00
Russ Cox
e1b2e20217 http: sniffing placeholder
R=dsymonds
CC=golang-dev
https://golang.org/cl/4746041
2011-07-15 01:01:49 -04:00
Brad Fitzpatrick
fc7b42325a cgi: make test less flaky
Previously, during the anti-zombie test, a
CGI process had to finish within ~625ms.
Now it gets ~5.6 seconds.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4741041
2011-07-14 17:00:14 -07:00
Robert Griesemer
90564a9256 go/printer: changed max. number of newlines from 3 to 2
manual changes in src/pkg/go/printer, src/cmd/gofix/signal_test.go
(cd src/cmd/gofix/testdata; gofmt -w *.in *.out)
(cd src/pkg/go/printer; gotest -update)
gofmt -w misc src

runs all tests

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4715041
2011-07-14 14:39:40 -07:00
Brad Fitzpatrick
8ba48fb5ca fix build from e904b6784768 breakage
R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4696047
2011-07-13 15:48:57 -07:00
Yasuhiro Matsumoto
2012290c7e http: fix Content-Type of file extension.
ServeFile() pass empty string to serveFile(). serveFile() should get
file extension via joining root and filename.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4654089
2011-07-13 14:39:33 -07:00
Brad Fitzpatrick
ce3c3953be http: support for periodic flushing in ReverseProxy
Fixes #2012

R=golang-dev, dsymonds
CC=golang-dev
https://golang.org/cl/4662091
2011-07-11 20:56:21 -07:00
Brad Fitzpatrick
1722ec22cd cgi: close stdout reader pipe when finished
This causes the child, if still writing, to get an error or
SIGPIPE and most likely exit so our subsequent wait can
finish.

A more guaranteed fix would be putting a time limit on the
child's overall execution, but this fixes the problem
I was having.

Fixes #2059

R=rsc
CC=golang-dev
https://golang.org/cl/4675081
2011-07-11 15:59:27 -07:00
Andrew Balholm
b053400e37 http: update triv.go with gofix
Sample code in triv.go wouldn't compile because it didn't use the new
FileSystem interface.
This was discussed on golang-nuts on July 7.
https://groups.google.com/forum/#!topic/golang-nuts/NMhZk3Ft_Vc

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4684044
2011-07-09 15:10:39 -07:00
Andrew Gerrand
5bcbcab311 sort: rename helpers: s/Sort// in sort.Sort[Float64s|Ints|Strings]
Includes 'sorthelpers' gofix and updates to tree.

R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/4631098
2011-07-08 10:52:50 +10:00
Brad Fitzpatrick
3236097ab0 cgi: don't depend on CGI.pm for tests
CGI.pm used to be part of the Perl core,
but some distros now bundle perl-core
and perl-modules separately.

It's not worth depending on.

R=golang-dev, mattn.jp
CC=golang-dev
https://golang.org/cl/4675063
2011-07-07 17:45:28 -07:00
Yasuhiro Matsumoto
2f9fbad043 http/cgi: add Handler.Dir to specify working directory
R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/4635042
2011-06-30 09:44:23 -07:00
Brad Fitzpatrick
d980f538d7 http: document that ServerConn and ClientConn are low-level
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4635081
2011-06-29 18:23:38 -07:00
Andrew Balholm
7983ab9d1a http: make NewChunkedReader public
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/4634112
2011-06-29 12:27:53 -07:00
Rob Pike
ebb1566a46 strings.Split: make the default to split all.
Change the signature of Split to have no count,
assuming a full split, and rename the existing
Split with a count to SplitN.
Do the same to package bytes.
Add a gofix module.

R=adg, dsymonds, alex.brainman, rsc
CC=golang-dev
https://golang.org/cl/4661051
2011-06-28 09:43:14 +10:00
Brad Fitzpatrick
ac213ab834 http: respect Handlers setting Connection: close in their response
Fixes #2011

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4667043
2011-06-27 15:53:48 -07:00