aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/requestwrite_test.go
AgeCommit message (Collapse)Author
2011-11-03net: renamingsRob Pike
This is Go 1 package renaming CL #3. This one merely moves the source; the import strings will be changed after the next weekly release. This one moves pieces into net. http -> net/http http/cgi -> net/http/cgi http/fcgi -> net/http/fcgi http/pprof -> net/http/pprof http/httptest -> net/http/httptest mail -> net/mail rpc -> net/rpc rpc/jsonrpc -> net/rpc/jsonrpc smtp -> net/smtp url -> net/url Also remove rand (now math/rand) from NOTEST - it has a test. The only edits are in Makefiles and deps.bash. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5335048
2011-11-01src/pkg/[a-m]*: gofix -r error -force=errorRuss Cox
R=golang-dev, iant CC=golang-dev https://golang.org/cl/5322051
2011-10-12http: remove Request.RawURLBrad Fitzpatrick
Its purpose is not only undocumented, it's also unknown (to me and Russ, at least) and leads to complexity, bugs and confusion. R=golang-dev, adg, rsc CC=golang-dev https://golang.org/cl/5213043
2011-09-19http: always include Content-Length header, even for 0Dave Grijalva
fixes #2221 R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/4952052
2011-09-19http: prevent DumpRequest from adding implicit headersBrad Fitzpatrick
Fixes #2272 R=rsc CC=golang-dev https://golang.org/cl/5043051
2011-09-19http: check explicit wrong Request.ContentLength valuesBrad Fitzpatrick
R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5070041
2011-08-17url: new packageRob Pike
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-06-24http: better handling of 0-length Request.BodyBrad Fitzpatrick
As rsc suggested after change 58a6bdac3d12 was committed, we now read the first byte of Request.Body when the Request.ContentLength is 0 to disambiguate between a truly zero-length body and a body of unknown length where the user didn't set the ContentLength field. This was also causing the reverse proxy problem where incoming requests (which always have a body, of private type http.body, even for 0-lengthed requests) were being relayed to the http Transport for fetching, which was serializing the request as a chunked request (since ContentLength was 0 and Body was non-nil) Fixes #1999 R=golang-dev, kevlar CC=golang-dev https://golang.org/cl/4628063
2011-06-16http: make Headers be source of truthBrad Fitzpatrick
Previously Request and Response had redundant fields for Referer, UserAgent, and cookies which caused confusion and bugs. It also didn't allow us to expand the package over time, since the way to access fields would be in the Headers one day and promoted to a field the next day. That would be hard to gofix, especially with code ranging over Headers. After a discussion on the mail package's design with a similar problem, we've designed to make the Headers be the source of truth and add accessors instead. Request: change: Referer -> Referer() change: UserAgent -> UserAgent() change: Cookie -> Cookies() new: Cookie(name) *Cookie new: AddCookie(*Cookie) Response: change: Cookie -> Cookies() Cookie: new: String() string R=rsc CC=golang-dev https://golang.org/cl/4620049
2011-06-08http: fix handling of 0-lengthed http requestsBrad Fitzpatrick
Via Russ Ross' bug report on golang-nuts, it was not possible to send an HTTP request with a zero length body with either a Content-Length (it was stripped) or chunking (it wasn't set). This means Go couldn't upload 0-length objects to Amazon S3. (which aren't as silly as they might sound, as S3 objects can have key/values associated with them, set in the headers) Amazon further doesn't supported chunked uploads. (not Go's problem, but we should be able to let users set an explicit Content-Length, even if it's zero.) To fix the ambiguity of an explicit zero Content-Length and the Request struct's default zero value, users need to explicit set TransferEncoding to []string{"identity"} to force the Request.Write to include a Content-Length: 0. identity is in RFC 2616 but is ignored pretty much everywhere. We don't even then serialize it on the wire, since it's kinda useless, except as an internal sentinel value. The "identity" value is then documented, but most users can ignore that because NewRequest now sets that. And adds more tests. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/4603041
2011-05-31http: have client set Content-Length when possibleBrad Fitzpatrick
Also some cleanup, removing redundant code. Make more things use NewRequest. Add some tests, docs. R=golang-dev, adg, rsc CC=golang-dev https://golang.org/cl/4561047
2011-05-20http: include Host header in requests, even with proxiesBrad Fitzpatrick
A user pointed out that Go didn't work with their corp proxy, always throwing 400 Bad Request errors. Looking at the RFC 2616, Host is always required, even with proxies. The old code assumed that writing an absolute URL in the first line of an HTTP request implied that the Host header was no longer necessary. Double-checked behavior with curl. R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/4539075
2011-04-14http: add NewRequest helperBrad Fitzpatrick
NewRequest will save a lot of boilerplate code. This also updates some docs on Request.Write and adds some tests. R=rsc, petar-m, r CC=golang-dev https://golang.org/cl/4406047
2011-03-12ioutil: add NopCloserBrad Fitzpatrick
R=rsc, dsymonds CC=golang-dev https://golang.org/cl/4278044
2011-03-06http: use Header type consistentlyRuss Cox
R=bradfitzgo, dsymonds CC=golang-dev https://golang.org/cl/4244053
2011-03-05http: fix, use WriteProxyRuss Cox
Fixes #53. R=bradfitzgo, bradfitzwork CC=golang-dev https://golang.org/cl/4240075
2011-02-23http: introduce Header type, implement with net/textprotoPetar Maymounkov
textproto: introduce Header type websocket: use new interface to access Header R=rsc, mattn CC=golang-dev https://golang.org/cl/4185053
2010-10-22gofmt -s -w src miscRobert Griesemer
R=r, rsc CC=golang-dev https://golang.org/cl/2662041
2010-09-27http: correct escaping of different parts of URLRuss Cox
Fixes #1076. R=adg CC=golang-dev https://golang.org/cl/2248045
2010-03-16http: change RawPath to mean raw path, not raw everything-after-scheme.Russ Cox
The new meaning is more useful for both websocket and http. R=r, petar-m, ukai CC=golang-dev, madari https://golang.org/cl/582043
2010-03-04gofmt: modified algorithm for alignment of multi-line composite/list entriesRobert Griesemer
- only manual changes are in src/pkg/go/printer/nodes.go - use a heuristic to determine "outliers" such that not entire composites are forced to align with them - improves several places that were not unligned before due too simple heuristic - unalignes some cases that contain "outliers" - gofmt -w src misc Fixes #644. R=rsc, r CC=golang-dev https://golang.org/cl/241041
2010-03-02gofmt: experiment: align values in map composites where possibleRobert Griesemer
- gofmt -w src misc - looking for feedback R=rsc, r CC=golang-dev https://golang.org/cl/223076
2010-02-24http: fix handling of Close, use Close in http.PostRuss Cox
default to HTTP/1.1 R=petar-m CC=golang-dev https://golang.org/cl/224041
2010-02-22http: use RawURL in Request.WritePetar Maymounkov
R=rsc CC=golang-dev https://golang.org/cl/217066
2010-02-19http: unified body transfer (read & write) logic in http.Request/Response.Petar Maymounkov
Compliance issue addressed here: POST requests carrying form data are required to use "identity" transfer encoding by common nginx and apache server configurations, e.g. wordpress.com (and many others). So, Request needed to be able to send non-chunked encodings. Thus, Request is extended to support identity and chunked encodings, like Response. Since the Read() and Write() logic are shared by both (and are quite long), it is exported in a separate file transfer.go. R=rsc CC=golang-dev https://golang.org/cl/217048
2010-02-10Added tests for http.Request/Response.Write()Petar Maymounkov
R=rsc CC=golang-dev https://golang.org/cl/199070