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

388 Commits

Author SHA1 Message Date
Brad Fitzpatrick
b88be14982 http/spdy: temporarily disable some failing tests
Issue 1886 has details

R=golang-dev, willchan
CC=golang-dev
https://golang.org/cl/4527083
2011-05-27 10:08:31 -07:00
William Chan
abb970ef57 http/spdy: redo interfaces, flesh out implementation & frame types
Added a new Framer to handle reading/writing Frames. This is necessary since we have to maintain a compression context across streams.

TODO:
* Separate the types and read/write routines into different files.
* Improve error handling.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4503042
2011-05-26 09:54:54 -07:00
Brad Fitzpatrick
0836b86e8b http: Transport hook to register non-http(s) protocols
This permits external packages implementing e.g.
FTP or gopher to register themselves with the
http.DefaultClient:

package ftp
func init() {
    http.DefaultTransport.RegisterProtocol("ftp", &ftp{})
}

Client code would look like:

import (
    _ "github.com/exampleuser/go/gopher"
    _ "github.com/exampleuser/go/ftp"
)

func main() {
    resp, err := http.Get("ftp://example.com/path.txt")
    ...
}

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/4526077
2011-05-25 12:31:11 -07:00
Brad Fitzpatrick
1b6bf88767 encoding/base64: add DecodeString and EncodeToString
... like encoding/hex. Same signatures.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4530070
2011-05-25 12:24:36 -07:00
Brad Fitzpatrick
b0f39cc27c io, net, http: sendfile support
Speeds up static fileserver, avoiding kernel/userspace copies.

Numbers: downloading 14 MB AppEngine Go SDK with ab (Apache Bench)
with 5 threads:

Before/after numbers:

CPU:
user    0m3.910s
sys     0m23.650s
->
user    0m0.720s
sys     0m4.890s

Time taken for tests:   8.906 seconds
->
Time taken for tests:   8.545 seconds

Percentage of the requests served within a certain time (ms)
50%     44
66%     45
75%     46
80%     46
90%     48
95%     51
98%     59
99%     71
100     74 (longest request)
->
50%     42
66%     43
75%     43
80%     44
90%     46
95%     57
98%     62
99%     63
100%    64 (longest request)

R=iant, gary.burd, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4543071
2011-05-25 10:15:26 -07:00
Brad Fitzpatrick
b32ad8bff5 http: Client test for streaming responses (no code changes)
I had a report that this was broken. It seems fine.

I think the reporter was just never flushing their response
headers.  If I omit the test server's initial Flush I get the
same behavior as reported. (a hang at Client.Get)

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4552062
2011-05-24 09:02:01 -07:00
Brad Fitzpatrick
3933cb2371 http: fix Set-Cookie date parsing
Fixes #1855

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/4527073
2011-05-24 08:31:43 -07:00
Brad Fitzpatrick
ccafd53ed3 http: add docs/warning on incorrect use of NewChunkedWriter
R=golang-dev, adg, r
CC=golang-dev
https://golang.org/cl/4536075
2011-05-22 18:46:48 -07:00
Brad Fitzpatrick
e4b942245a http: include Host header in requests, even with proxies
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-05-20 19:40:23 -07:00
Robert Griesemer
b790ae2efb go/printer, gofmt: fix formatting of expression lists (missing blank)
This appears to have been a long-standing formatting bug.
The test cases has misformatted golden files.

Applied gofmt -w src misc .

Fixes #1839.

R=iant
CC=golang-dev
https://golang.org/cl/4515113
2011-05-19 17:05:35 -07:00
Brad Fitzpatrick
4ffff35abd http: Client.Do should follow redirects for GET and HEAD
It's documented as such, but it was never wired up
after Transport went in and Head was fixed.

If people don't want redirects, that's what RoundTripper/
Transport are for.  Or a custom redirect policy.

R=golang-dev, kevlar
CC=golang-dev
https://golang.org/cl/4526065
2011-05-18 17:17:26 -07:00
Robert Hencke
c8727c81bb pkg: spelling tweaks, A-H
R=ality, bradfitz, rsc, dsymonds, adg, qyzhai, dchest
CC=golang-dev
https://golang.org/cl/4536063
2011-05-18 13:14:56 -04:00
Brad Fitzpatrick
feca99fd6f http: add Transport.ProxySelector
R=mattn.jp, rsc
CC=golang-dev
https://golang.org/cl/4528077
2011-05-18 09:23:29 -07:00
Brad Fitzpatrick
9ea0bd3986 http: add http.SetCookie(ResponseWriter, *Cookie)
R=golang-dev, gary.burd, rsc
CC=golang-dev
https://golang.org/cl/4526062
2011-05-17 15:07:44 -07:00
Mikio Hara
db36e03692 net, http: add and make use of IP address scope identification API
Add seven methods to IP struct: IsUnspecified, IsLoopback,
IsMulticast, IsInterfaceLocalMulticast, IsLinkLocalMulticast,
IsLinkLocalUnicast and IsGlobalUnicast.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4515083
2011-05-16 23:21:13 -04:00
Robert Hencke
cc2fc02467 pkg: fix incorrect prints found by govet
Also, clarify some error messages

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4548042
2011-05-14 20:43:18 -07:00
Brad Fitzpatrick
cd4d0004fa http: add Request.SetBasicAuth method
R=golang-dev, dsymonds, rsc
CC=golang-dev
https://golang.org/cl/4543050
2011-05-13 15:43:46 -07:00
Eivind Uggedal
092f34feca http: make HEAD client request follow redirects
HEAD requests should in my opinion have the ability to follow redirects
like the implementation of GET requests does. My use case is polling
several thousand severs to check if they respond with 200 status codes.
Using GET requests is neither efficient in running time of the task nor
for bandwidth consumption.

This suggested patch changes the return signature of http.Head() to match
that of http.Get(), providing the final URL in a redirect chain.

`curl -IL http://google.com` follows redirects with HEAD requests just fine.

Fixes #1806.

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/4517058
2011-05-13 08:17:59 -07:00
Brad Fitzpatrick
05a1b7ec41 http: remove finalURL from Client.Get; move to Response
This CL:

-- removes Response.RequestMethod string
-- adds Response.Request *Request
-- removes the finalURL result parameter from client.Get()
-- adds a gofix rule for callers of http.Get which assign
   the final url to the blank identifier; warning otherwise

Caller who did:

res, finalURL, err := http.Get(...)

now need to do:

res, err := http.Get(...)
if err != nil {
   ...
}
finalURL := res.Request.URL.String()

R=rsc
CC=golang-dev
https://golang.org/cl/4535056
2011-05-13 07:31:24 -07:00
Brad Fitzpatrick
fa23a70044 http: fix two Transport gzip+persist crashes
There were a couple issues:

-- HEAD requests were attempting to be ungzipped,
   despite having no content.  That was fixed in
   the previous patch version, but ultimately was
   fixed as a result of other refactoring:

-- persist.go's ClientConn "lastbody" field was
   remembering the wrong body, since we were
   mucking with it later. Instead, ditch
   ClientConn's readRes func field and add a new
   method passing it in, so we can use a closure
   and do all our bodyEOFSignal + gunzip stuff
   in one place, simplifying a lot of code and
   not requiring messing with ClientConn's innards.

-- closing the gzip reader didn't consume its
   contents.  if the caller wasn't done reading
   all the response body and ClientConn closed it
   (thinking it'd move past those bytes in the
   TCP stream), it actually wouldn't.  so introduce
   a new wrapper just for gzip reader to have its
   Close method do an ioutil.Discard on its body
   first, before the close.

Fixes #1725
Fixes #1804

R=rsc, eivind
CC=golang-dev
https://golang.org/cl/4523058
2011-05-11 22:33:15 -04:00
Christian Himpel
158970ea66 http: write cookies according to RFC 6265
RFC 6265 requires that user agents MUST NOT send more than
one Cookie header in a request.

Note, this change also fixes an issue when sending requests
with more than one cookie header line to a php script served
by an apache web server.  Apache concatenates the cookies
with ", ", but php tries to split them only at ";".  E.g.
two cookies: "a=b, c=d" are seen by php as one cookie "a"
with the value "b, c=d".

Fixes #1801

R=bradfitz
CC=golang-dev
https://golang.org/cl/4535048
2011-05-11 13:33:27 -07:00
Brad Fitzpatrick
ca83cd2c2f http: fix transport bug with zero-length bodies
An optimization in Transport which re-uses TCP
connections early in the case where there is
no response body interacted poorly with
ErrBodyReadAfterClose.  Upon recycling the TCP
connection early we would Close the Response.Body
(in case the user forgot to), but in the case
of a zero-lengthed body, the user's handler might
not have run yet.

This CL makes sure the Transport doesn't try
to Close requests when we're about to immediately
re-use the TCP connection.

This also includes additional tests I wrote
while debugging.

R=rsc, bradfitzgoog
CC=golang-dev
https://golang.org/cl/4529050
2011-05-11 12:11:32 -07:00
Brad Fitzpatrick
b276293aba http: don't Clean query string in relative redirects
R=adg, rsc, kevlar, r
CC=golang-dev
https://golang.org/cl/4476045
2011-05-11 04:30:05 -07:00
Robert Griesemer
499ad9448b go/printer, gofmt: fix alignment of "=" in const/var declarations
gofmt -w src misc

Fixes #1414.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4456054
2011-05-09 15:16:34 -07:00
David Symonds
606e12f9bf http: fix typo in URL.String doc comment.
R=adg
CC=golang-dev
https://golang.org/cl/4485046
2011-05-06 10:00:50 -07:00
Ross Light
bcf3bfe2fe http/spdy: add type to FlagClearPreviouslyPersistedSettings constant
R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4436074
2011-05-04 15:01:33 -04:00
Andrew Gerrand
73f4b847ae http: fix FormFile nil pointer dereference on missing multipart form
R=rsc
CC=golang-dev
https://golang.org/cl/4463042
2011-05-03 20:45:10 -07:00
Brad Fitzpatrick
4b30d7cead http: improve a test
Should prevent failures on slow machines, such as:
http://godashboard.appspot.com/log/47b5cae591b7ad8908704e327f3b9b41945d7d5fecfc0c8c945d5545ece1a813

Verified the change (on a fast machine) by removing the
existing sleep, in which case the race happens ~50% of the
time with GOMAXPROCS > 1, but recovers gracefully with
retries.

R=rsc
CC=golang-dev
https://golang.org/cl/4441089
2011-05-03 11:25:35 -07:00
Russ Cox
4002014cf8 http/pprof: fix POST reading bug
R=bradfitz
CC=golang-dev
https://golang.org/cl/4430075
2011-05-02 17:34:22 -04:00
Brad Fitzpatrick
f279a93929 http: fix racy test with a simpler version
This was seen breaking the slow arm5 builder:
http://godashboard.appspot.com/log/ec54ee302a70c07093e8f5c47454b3eb48768b77e1d8cc7943d8951f8b6696be

The test was unnecessarily complex and didn't benefit from
using httptest.Server. That just got in the way.

R=rsc
CC=golang-dev
https://golang.org/cl/4439088
2011-05-02 13:01:36 -07:00
Andrew Gerrand
89adf5dce4 http: rename ErrBodyReadAferClose to ErrBodyReadAfterClose
R=bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/4432085
2011-05-01 12:37:20 -07:00
Brad Fitzpatrick
cb375ffbb0 http: new error for reading a body after it's been closed
R=adg
CC=golang-dev
https://golang.org/cl/4433094
2011-04-30 19:54:08 -07:00
Ian Lance Taylor
2e7d6729d4 http/cgi: pass down environment variables for irix and solaris
Used by gccgo.

R=bradfitz
CC=golang-dev
https://golang.org/cl/4435080
2011-04-29 10:38:07 -07:00
Evan Shaw
0add1c3ed8 http/cgi: correctly set request Content-Type
R=bradfitz
CC=golang-dev
https://golang.org/cl/4433087
2011-04-29 07:04:28 -07:00
Brad Fitzpatrick
548c9c8624 cgi: set Request.TLS and Request.RemoteAddr for children
R=agl, eds, rsc1, rsc
CC=golang-dev
https://golang.org/cl/4432079
2011-04-28 15:02:32 -07:00
Evan Shaw
98945a2bad cgi: export RequestFromMap
R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4452056
2011-04-28 13:30:53 -07:00
Ross Light
1801972b30 http/spdy: new package
R=bradfitz, agl1, rsc
CC=golang-dev
https://golang.org/cl/4435055
2011-04-28 13:11:37 -07:00
Brad Fitzpatrick
df2c5d5429 http: update cookie doc to reference new RFC 6265
R=rsc, r2
CC=golang-dev
https://golang.org/cl/4442100
2011-04-28 11:36:06 -07:00
Evan Shaw
f319e1df37 http: add Header.Write method
R=golang-dev, bradfitz, dsymonds
CC=golang-dev
https://golang.org/cl/4426069
2011-04-28 00:16:15 -07:00
Andrew Gerrand
200bd0a057 http: add MultipartForm, FormFile, and ParseMultipartForm to Request
R=rsc, bradfitz
CC=golang-dev
https://golang.org/cl/4431068
2011-04-28 15:21:54 +10:00
Brad Fitzpatrick
9d12307a12 ioutil: add Discard, update tree.
This also removes an unnecessary allocation in
http/transfer.go

R=r, rsc1, r2, adg
CC=golang-dev
https://golang.org/cl/4426066
2011-04-27 15:47:04 -07:00
Brad Fitzpatrick
ec3fe2a5b6 http: put a limit on POST size
R=rsc
CC=golang-dev
https://golang.org/cl/4432076
2011-04-27 15:36:39 -07:00
Brad Fitzpatrick
6e71e1ca76 http: keep gzip reader inside eofsignaler
Fixes #1725

R=rsc
CC=golang-dev
https://golang.org/cl/4442086
2011-04-27 14:23:25 -07:00
Brad Fitzpatrick
b477a79c4e cgi: improve Location response handling
Add local URI path support, which isn't as fringe
as I originally thought. (it's supported by Apache)

Send an implicit 302 status on redirects (not 200).

Fixes #1597

R=rsc, r
CC=golang-dev
https://golang.org/cl/4442089
2011-04-27 14:07:13 -07:00
Evan Shaw
87ac7c77c0 http/fcgi: New package
R=golang-dev, bradfitzgo, bradfitzwork, nigeltao, rog
CC=golang-dev
https://golang.org/cl/4271078
2011-04-27 12:34:34 -07:00
Brad Fitzpatrick
214b82f2e0 http: new tests + panic hunting issue 1725
No bugs found yet, though.

R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4436058
2011-04-26 12:32:59 -07:00
Brad Fitzpatrick
1038e7c853 http: make Client redirect policy configurable
Work on issue 155

R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4435071
2011-04-25 22:41:50 -07:00
Russ Cox
07abf1c732 fix tree for reflect rename
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4435067
2011-04-25 13:39:36 -04:00
Petar Maymounkov
f589728ff4 http: in ServerConn and ClientConn, rename Close to Hijack, add Close
R=rsc
CC=golang-dev
https://golang.org/cl/4372046
2011-04-22 15:56:27 -04:00
Brad Fitzpatrick
c94db30ec9 http/cgi: pass some default environment variables
This isn't really part of RFC 3875 but matches
the behavior of Apache, et al.

R=iant, iant2
CC=golang-dev
https://golang.org/cl/4435065
2011-04-22 11:02:33 -07:00
Brad Fitzpatrick
81cfb4ec2b http: fix FileServer's default text content type
Fixes #1729

R=rsc, adg
CC=golang-dev
https://golang.org/cl/4443057
2011-04-22 09:09:37 -07:00
Ian Lance Taylor
75ca6d189c http/cgi: copy some PATH environment variables to child
R=bradfitz, bradfitzwork, iant2, bradfitzgo
CC=golang-dev
https://golang.org/cl/4444058
2011-04-22 08:53:52 -07:00
Brad Fitzpatrick
8d6a12f570 http: clarify docs on Request HTTP version
Fixes #910

R=adg, rsc1
CC=golang-dev
https://golang.org/cl/4439062
2011-04-21 19:57:19 -07:00
Brad Fitzpatrick
750b6c63f9 http: close underlying gzip Reader too
Fixes #1724

R=rsc
CC=golang-dev
https://golang.org/cl/4443056
2011-04-21 16:01:29 -07:00
Brad Fitzpatrick
8dad7fec1d http: don't proxy loopback addresses
Fixes #1589

R=rsc
CC=golang-dev
https://golang.org/cl/4443053
2011-04-20 13:53:34 -07:00
Nigel Tao
6a186d38d1 src/pkg: make package doc comments consistently start with "Package foo".
R=rsc
CC=golang-dev
https://golang.org/cl/4442064
2011-04-20 09:57:05 +10:00
Russ Cox
857f17d346 http: fix IP confusion in TestServerTimeouts
Don't assume that localhost == 127.0.0.1.
It might be ::1.

R=bradfitzgo
CC=golang-dev
https://golang.org/cl/4430055
2011-04-18 16:03:24 -04:00
Brad Fitzpatrick
4787e70b7b http: handler timeout support
Fixes #213

R=r, rsc
CC=golang-dev
https://golang.org/cl/4432043
2011-04-15 12:53:32 -07:00
Brad Fitzpatrick
e806565626 http: reverse proxy handler
R=rsc, petar-m
CC=golang-dev
https://golang.org/cl/4428041
2011-04-15 08:13:52 -07:00
Brad Fitzpatrick
71f9dc2cea http: add NewRequest helper
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-04-14 20:36:52 -07:00
Petar Maymounkov
8b35293070 http: don't quote Set-Cookie Domain and Path
Fixes #1659

R=rsc, bradfitzgo, bradfitzwork
CC=bradfitz, golang-dev
https://golang.org/cl/4368052
2011-04-14 15:05:02 -07:00
Brad Fitzpatrick
881b1b4a02 http: be clear when failing to connect to a proxy
Ubuntu and/or GNOME have some bug that likes
to set the "http_proxy" environment variable
and forgets to unset it.  This is annoying
to debug.  Be clear in the error message that
a proxy was in use.

R=rsc
CC=golang-dev
https://golang.org/cl/4409045
2011-04-14 13:49:19 -07:00
Brad Fitzpatrick
e27702545a http: consume request bodies before replying
This fixes our http behavior (even if Handlers forget to
consume a request body, we do it for them before we send
their response header), fixes the racy TestServerExpect,
and adds TestServerConsumesRequestBody.

With GOMAXPROCS>1, the http tests now seem race-free.

R=rsc
CC=golang-dev
https://golang.org/cl/4419042
2011-04-14 10:40:23 -07:00
Brad Fitzpatrick
e0533b044d http: fix race in transport_test
R=rsc
CC=golang-dev
https://golang.org/cl/4414044
2011-04-14 09:07:20 -07:00
Robert Griesemer
a2e286828b gofmt: gofmt -s -w src misc
R=r, bradfitzwork
CC=golang-dev
https://golang.org/cl/4406044
2011-04-13 15:13:59 -07:00
Brad Fitzpatrick
c7d16cc411 http: flesh out server Expect handling + tests
This mostly adds Expect 100-continue tests (from
the perspective of server correctness) that were
missing before.

It also fixes a few missing cases that will
probably never come up in practice, but it's nice
to have handled correctly.

Proper 100-continue client support remains a TODO.

R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4399044
2011-04-13 14:09:04 -07:00
Adam Langley
6392fc75cf bufio: add ReadLine
It matches encoding/line exactly and the tests are copied from there.
If we land this, then encoding/line will get marked as deprecated then
deleted in time.

R=rsc, rog, peterGo
CC=golang-dev
https://golang.org/cl/4389046
2011-04-13 15:12:28 -04:00
Brad Fitzpatrick
92210eefb2 http: client gzip support
R=adg, rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4389048
2011-04-12 09:35:07 -07:00
Robert Hencke
d36271a3e5 http: fix incorrect prints found by govet
R=golang-dev, bradfitzgo
CC=golang-dev
https://golang.org/cl/4370053
2011-04-11 13:05:08 -07:00
Russ Cox
e6e2eb5807 http: do not listen on 0.0.0.0 during test
Quiets the pop-up boxes on OS X.

R=bradfitzgo, r2
CC=golang-dev
https://golang.org/cl/4387042
2011-04-08 13:04:29 -04:00
Russ Cox
db5c5d6fa6 update go tree for reflect changes
R=golang-dev, r
CC=golang-dev
https://golang.org/cl/4353043
2011-04-08 12:27:58 -04:00
Andrew Gerrand
b44dbff8c8 http: allow override of Content-Type for ServeFile
R=bradfitz, bradfitzwork
CC=golang-dev
https://golang.org/cl/4368041
2011-04-06 14:52:42 +10:00
Rob Pike
8a90fd3c72 os: New Open API.
We replace the current Open with:
OpenFile(name, flag, perm) // same as old Open
Open(name) // same as old Open(name, O_RDONLY, 0)
Create(name) // same as old Open(name, O_RDWR|O_TRUNC|O_CREAT, 0666)

This CL includes a gofix module and full code updates: all.bash passes.
(There may be a few comments I missed.)

The interesting packages are:
        gofix
        os
Everything else is automatically generated except for hand tweaks to:
        src/pkg/io/ioutil/ioutil.go
        src/pkg/io/ioutil/tempfile.go
        src/pkg/crypto/tls/generate_cert.go
        src/cmd/goyacc/goyacc.go
        src/cmd/goyacc/units.y

R=golang-dev, bradfitzwork, rsc, r2
CC=golang-dev
https://golang.org/cl/4357052
2011-04-04 23:42:14 -07:00
Brad Fitzpatrick
6e4966eb7f http: ignore Transfer-Encoding on HEAD responses
Amazon S3 sends Transfer-Encoding "chunked"
on its 404 responses to HEAD requests for
missing objects.

We weren't ignoring the Transfer-Encoding
and were thus interpretting the subsequent
response headers as a chunk header from the
previous responses body (but a HEAD response
can't have a body)

R=rsc, adg
CC=golang-dev
https://golang.org/cl/4346050
2011-04-04 19:43:36 -07:00
Brad Fitzpatrick
243266f62e http: fix Transport connection re-use race
A connection shouldn't be made available
for re-use until its body has been consumed.

(except in the case of pipelining, which isn't
implemented yet)

This CL fixes some issues seen with heavy load
against Amazon S3.

Subtle implementation detail: to prevent a race
with the client requesting a new connection
before previous one is returned, we actually
have to call putIdleConnection _before_ we
return from the final Read/Close call on the
http.Response.Body.

R=rsc, adg
CC=golang-dev
https://golang.org/cl/4351048
2011-04-04 19:22:47 -07:00
Brad Fitzpatrick
7c9c4fc3a1 http: fix hanging bug with HEAD responses
The transport readLoop was waiting forever for the client to
read the non-existent body before proceeding to read the next
request.

R=rsc
CC=golang-dev
https://golang.org/cl/4357051
2011-04-04 16:58:11 -07:00
Brad Fitzpatrick
2be13a80c7 os: add Seek whence constants
R=r, r2, rsc1, rsc, jacek.masiulaniec
CC=golang-dev
https://golang.org/cl/4344062
2011-04-04 13:53:52 -07:00
Matt Jones
5fd0a74987 http: use upper case hex in URL escaping
According to RFC 3986: "For consistency, URI producers
and normalizers should use uppercase hexadecimal digits
for all percent-encodings."  Using lower case characters
makes it incompatible with Google APIs when signing OAuth requests.

R=golang-dev, rsc1, rsc
CC=golang-dev
https://golang.org/cl/4352044
2011-04-04 15:49:49 -04:00
Brad Fitzpatrick
cc40870f4b httptest: add NewTLSServer
Enables the use of https servers in tests.

R=agl, rsc, agl1
CC=golang-dev
https://golang.org/cl/4284063
2011-04-04 08:32:59 -07:00
Brad Fitzpatrick
a2bcd3814d http: make triv.go example compile again
Ideally we'd compile all example files during
the build, though.

Fixes #1660

R=r
CC=golang-dev
https://golang.org/cl/4358049
2011-04-04 08:10:26 -07:00
Brad Fitzpatrick
883048daab http: add Transport.MaxIdleConnsPerHost
R=rsc
CC=golang-dev
https://golang.org/cl/4280079
2011-03-31 12:58:50 -07:00
Russ Cox
5546cc7eab update tree for package net changes
Converted with gofix.

R=adg
CC=golang-dev
https://golang.org/cl/4284049
2011-03-28 23:28:53 -04:00
Russ Cox
732f2fa2c1 http: avoid crash when asked for multiple file ranges
R=adg
CC=golang-dev
https://golang.org/cl/4289076
2011-03-27 23:35:31 -04:00
Russ Cox
e857dd5d3f http/pprof: cpu profiling support
R=r
CC=golang-dev
https://golang.org/cl/4280060
2011-03-25 12:50:12 -04:00
Roger Pau Monné
500effe79e http: modified perl cgi test to remove newline from env variables
Fixes #1639

R=golang-dev, bradfitzgo
CC=golang-dev
https://golang.org/cl/4291069
2011-03-25 09:33:45 -07:00
Brad Fitzpatrick
9d3b39986c http: don't chunk 304 responses
rsc's earlier fix, plus tests.

R=rsc
CC=golang-dev
https://golang.org/cl/4285062
2011-03-23 14:29:26 -07:00
Brad Fitzpatrick
059c07cab0 http: export Transport, add keep-alive support
This patch adds a connection cache and keep-alive
support to Transport, which is used by the
HTTP client.

It's also structured such that it's easy to add
HTTP pipelining in the future.

R=rsc, petar-m, bradfitzwork, r
CC=golang-dev
https://golang.org/cl/4272045
2011-03-23 10:38:18 -07:00
Brad Fitzpatrick
708013064f cgi: extra failure debugging in host_test
Trying to track down why this fails on some
people's machines.

R=rsc, adg, dsymonds
CC=golang-dev
https://golang.org/cl/4304041
2011-03-21 14:43:38 -07:00
Brad Fitzpatrick
a93f70c21a http: add NewProxyClientConn
This just returns a ClientConn suitable for writing
proxy requests.  To be used in Transport.

R=rsc, petar-m
CC=golang-dev
https://golang.org/cl/4290052
2011-03-16 14:32:35 -07:00
Roger Peppe
aa55c05213 os, syscall: add ProcAttr type. Change StartProcess etc. to use it.
The Windows code is untested.

R=rsc, gri, brainman, rsc1
CC=golang-dev
https://golang.org/cl/4253052
2011-03-15 14:41:19 -04:00
Brad Fitzpatrick
f192891786 httptest: default the Recorder status code to 200 on a Write
This matches the real ResponseWriter behavior.

R=rsc
CC=golang-dev
https://golang.org/cl/4291048
2011-03-15 10:13:25 -07:00
Brad Fitzpatrick
3479bb6c12 ioutil: add NopCloser
R=rsc, dsymonds
CC=golang-dev
https://golang.org/cl/4278044
2011-03-12 16:05:07 -08:00
Brad Fitzpatrick
1c96562f36 http: use Header.Del not empty Set(k, "")
Also don't serialize empty headers.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/4275045
2011-03-12 09:58:53 -08:00
Brad Fitzpatrick
d3d672998f http: rename interface Transport to RoundTripper
Transport.Do -> RoundTripper.RoundTrip

This makes way for a subsequent CL to export the
currently private RoundTripper implementation
as struct Transport.

R=rsc, r
CC=golang-dev
https://golang.org/cl/4286043
2011-03-11 11:32:33 -08:00
Brad Fitzpatrick
9554e67188 http: fix transport crash when request URL is nil
Fixes #1602

R=rsc, petar-m
CC=golang-dev
https://golang.org/cl/4284043
2011-03-11 09:54:31 -08:00
Brad Fitzpatrick
bbad6900ce http: run tests even with DISABLE_NET_TESTS=1
All tests are now localhost only.

R=rsc
CC=golang-dev
https://golang.org/cl/4271042
2011-03-10 10:19:11 -08:00
Brad Fitzpatrick
8e1fa76047 http: don't hit external network in client_test.go
More reliable.

R=rsc
CC=golang-dev
https://golang.org/cl/4249068
2011-03-10 08:46:57 -08:00
Brad Fitzpatrick
aae7b695ac http: move RemoteAddr & UsingTLS from ResponseWriter to Request
ResponseWriter.RemoteAddr() string -> Request.RemoteAddr string
ResponseWriter.UsingTLS() bool -> Request.TLS *tls.ConnectionState

R=rsc, bradfitzwork
CC=gburd, golang-dev
https://golang.org/cl/4248075
2011-03-10 08:17:22 -08:00
Brad Fitzpatrick
ec5c475919 http: add Flusher type; remove Flush from ResponseWriter
The Flush functionality wasn't removed, but now you have
to test if your ResponseWriter is also a Flusher:

func ServeHTTP(rw http.ResponseWriter, req *http.Request) {
   if f, ok := rw.(http.Flusher); ok {
       f.Flush()
   }
}

R=rsc, bradfitzwork
CC=gburd, golang-dev
https://golang.org/cl/4239077
2011-03-09 10:24:50 -08:00
Brad Fitzpatrick
2c420ece67 http: change ResponseWriter.SetHeader(k,v) to Header() accessor
Caller code needs to change:

rw.SetHeader("Content-Type", "text/plain")
to:
rw.Header().Set("Content-Type", "text/plain")

This now permits returning multiple headers
with the same name using Add:

rw.Header().Add("Set-Cookie", "..")
rw.Header().Add("Set-Cookie", "..")

This patch also fixes serialization of headers, removing newline characters.

Fixes #488
Fixes #914

R=rsc
CC=gburd, golang-dev
https://golang.org/cl/4239076
2011-03-09 09:41:01 -08:00
Brad Fitzpatrick
d64a18a27e cgi: child support (e.g. Go CGI under Apache)
The http/cgi package now supports both being
a CGI host or being a CGI child process.

R=rsc, adg, bradfitzwork
CC=golang-dev
https://golang.org/cl/4245070
2011-03-08 08:01:19 -08:00
Andrew Gerrand
d2e011d518 http: add test for recently fixed HTTP/1.0 keep-alive issue
R=bradfitzgo, rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4235056
2011-03-08 16:12:44 +11:00
Brad Fitzpatrick
2168e6aaf1 http: change Hijacker to return a net.Conn
net.Conn is itself a io.ReadWriteCloser, so
most code should be unaffected.

R=rsc, gburd
CC=golang-dev
https://golang.org/cl/4261052
2011-03-07 12:04:04 -08:00
Russ Cox
792ff38604 http: fix cookie_test
Was only breaking on some dashboard builds because
not all run the network tests.

R=bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4240086
2011-03-07 14:45:45 -05:00
Petar Maymounkov
3e042ebb57 http: adapt Cookie code to follow IETF draft
R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4235055
2011-03-07 12:08:39 -05:00
Russ Cox
c4407b7552 http: close after responding to HTTP/1.0 request without Connection: keep-alive
R=adg
CC=golang-dev
https://golang.org/cl/4245065
2011-03-07 00:14:40 -05:00
Russ Cox
0db312b6a8 http: use Header type consistently
R=bradfitzgo, dsymonds
CC=golang-dev
https://golang.org/cl/4244053
2011-03-06 23:02:29 -05:00
Brad Fitzpatrick
545a1eef6a http: add Hijacker type; remove Hijack from ResponseWriter
The Hijack functionality wasn't removed, but now you have
to test if your ResponseWriter is also a Hijacker:

func ServeHTTP(rw http.ResponseWriter, req *http.Request) {
    if hj, ok := rw.(http.Hijacker); ok {
        hj.Hijack(..)
    }
}

R=rsc
CC=golang-dev
https://golang.org/cl/4245064
2011-03-06 18:59:50 -08:00
Gustavo Niemeyer
04ca4f8242 path/filepath: new OS-specific path support
The path package now contains only functions which
deal with slashed paths, sensible for any OS when dealing
with network paths or URLs.  OS-specific functionality
has been moved into the new path/filepath package.

This also includes fixes for godoc, goinstall and other
packages which were mixing slashed and OS-specific paths.

R=rsc, gri, mattn, brainman
CC=golang-dev
https://golang.org/cl/4252044
2011-03-06 17:33:23 -05:00
Petar Maymounkov
6afe7eba32 http: add cookie support
R=rsc1, mattn, bradfitzwork, pascal, bradfitzgo
CC=golang-dev
https://golang.org/cl/4214042
2011-03-06 15:02:06 -05:00
Russ Cox
255b538152 http/cgi: skip test if perl or CGI.pm not available
R=bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4264047
2011-03-06 11:23:47 -05:00
Brad Fitzpatrick
bfd3d81b92 httptest: fix docs out-of-sync from earlier renaming
R=rh
CC=golang-dev
https://golang.org/cl/4239060
2011-03-05 15:43:26 -08:00
Brad Fitzpatrick
f88abdad0f httptest: introduce TempServer, clean up tests
This also breaks fs_test into two parts
as the range tests test http's private httpRange
and I had to change the fs_test package from
"http" to "http_test" to use httptest which otherwise
has a cyclic depedency back on http.

Aside: we should start exposing the Range
stuff in the future.

R=rsc
CC=golang-dev
https://golang.org/cl/4261047
2011-03-05 13:51:35 -08:00
Petar Maymounkov
5db0a8b9ef http: fixed race condition in persist.go
R=rsc, bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4266042
2011-03-05 14:44:05 -05:00
Russ Cox
7bc90eda69 http: fix, use WriteProxy
Fixes #53.

R=bradfitzgo, bradfitzwork
CC=golang-dev
https://golang.org/cl/4240075
2011-03-05 14:35:15 -05:00
Brad Fitzpatrick
99f17aa0b8 http/cgi: skip tests on Windows
The tests require Perl, not commonly installed on Windows.

R=rsc, brainman
CC=golang-dev
https://golang.org/cl/4239057
2011-03-04 14:12:39 -08:00
Brad Fitzpatrick
7b563be516 http: rename ClientTransport to Transport
http.Transport looks nicer, and ServerTransport
doesn't make much sense anyway.

R=rsc
CC=golang-dev
https://golang.org/cl/4239056
2011-03-04 11:41:57 -08:00
Brad Fitzpatrick
da679db0f1 http: add packages http/cgi and http/httptest
R=rsc, adg, jnw, bradfitzwork
CC=golang-dev
https://golang.org/cl/4247048
2011-03-04 10:55:47 -08:00
Brad Fitzpatrick
38a105e48a http: change localhost URL; maybe fix Windows
R=golang-dev, rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4259048
2011-03-03 13:29:31 -08:00
Brad Fitzpatrick
61fd11ef96 http: allow handlers to send non-chunked responses
Currently all http handlers reply to HTTP/1.1 requests with
chunked responses.  This patch allows handlers to opt-out of
that behavior by pre-declaring their Content-Length (which is
then enforced) and unsetting their Transfer-Encoding or
setting it to the "identity" encoding.

R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4245058
2011-03-03 12:22:13 -08:00
Brad Fitzpatrick
9733f96b47 http: initialize request Header for the transport
Fixes #1558

R=rsc, r, bradfitzwork
CC=golang-dev
https://golang.org/cl/4260042
2011-03-02 10:21:56 -08:00
David Symonds
1d258a554a http: give ParseHTTPVersion a real example.
R=rsc
CC=golang-dev
https://golang.org/cl/4239050
2011-03-02 10:10:12 +11:00
Brad Fitzpatrick
60f193781d http: expose Client's Transport
This is again an intentionally minimal change.

The plan is to keep Client's zero value be a usable
client, with optional fields being added over time
(e.g. cookie manager, redirect policy, auth)

R=rsc
CC=golang-dev
https://golang.org/cl/4239044
2011-03-01 14:07:28 -08:00
David Symonds
7eaecb8915 http: export parseHTTPVersion.
R=rsc, adg
CC=golang-dev
https://golang.org/cl/4244045
2011-03-01 22:38:18 +11:00
Russ Cox
4185a9e2b2 http: remove debugging log statement
Issue 1547 is fixed.

R=bradfitzgo, r
CC=golang-dev
https://golang.org/cl/4209045
2011-02-24 14:36:18 -05:00
Brad Fitzpatrick
c7978584c3 http: set method GET on Get() requests
R=adg, bradfitzwork
CC=golang-dev
https://golang.org/cl/4229042
2011-02-23 15:03:30 -08:00
Brad Fitzpatrick
e0a2c5d4b5 http: introduce start of Client and ClientTransport
Much yet to come, but this is a safe first step, introducing
an in-the-future configurable Client object (where policy for
cookies, auth, redirects will live) as well as introducing a
ClientTransport interface for sending requests.

The CL intentionally ignores everything around the creation
and configuration of Clients and merely ports/wraps the old
interfaces to/around Client/ClientTransport.

R=rsc, dsymonds, nigeltao, bradfitzwork
CC=golang-dev
https://golang.org/cl/4182086
2011-02-23 12:20:50 -08:00
Petar Maymounkov
b8fa61885a http: introduce Header type, implement with net/textproto
textproto: introduce Header type
websocket: use new interface to access Header

R=rsc, mattn
CC=golang-dev
https://golang.org/cl/4185053
2011-02-23 00:39:25 -05:00
Andrew Gerrand
1e73fed888 http: add pointer from Handle[Func] to ServeMux docs
R=r
CC=golang-dev
https://golang.org/cl/4169065
2011-02-22 11:16:25 +11:00
Padraig Kitterick
1f39ed8a2d http: cleaned up HEAD request method.
Removed a redefinition of the request URL which is never used and
redundant checking of the return value from send().

R=golang-dev, adg
CC=golang-dev
https://golang.org/cl/4184061
2011-02-22 10:40:37 +11:00
Russ Cox
063125dfcf http: send full URL in proxy requests
Fixes #53.  (again)

R=agl1
CC=golang-dev
https://golang.org/cl/4167054
2011-02-17 17:14:50 -05:00
Yasuhiro Matsumoto
f04b5a3bac http: add proxy support
Fixes #53.

R=agl1, jacek.masiulaniec, adg, rsc, agl
CC=golang-dev
https://golang.org/cl/3794041
2011-02-16 14:06:50 -05:00
Petar Maymounkov
3de98466c8 http: add pipelining to ClientConn, ServerConn
R=rsc, bradfitzwork
CC=golang-dev
https://golang.org/cl/4082044
2011-02-11 15:05:47 -05:00
Brad Fitzpatrick
876e9d1b89 http: add Server type supporting timeouts
R=rsc
CC=golang-dev
https://golang.org/cl/4172041
2011-02-10 14:36:22 -08:00
Brad Fitzpatrick
2aaabfc828 http: handle unchunked, un-lengthed HTTP/1.1 responses
Fixes #716

This CL simply resumes the previous CL in-flight at
https://golang.org/cl/906042/

R=rsc, petar-m, dsymonds
CC=golang-dev
https://golang.org/cl/4157042
2011-02-08 20:35:02 -08:00
Alex Brainman
4ecebfea53 os: implement new Process api
Fixes #1004.
Fixes #1460.

R=mattn, r, niemeyer, rog, rsc
CC=golang-dev
https://golang.org/cl/4029053
2011-02-04 14:41:26 +11:00
Rob Pike
eea18d959e log: rename Exit* to Fatal*
This aligns the naming scheme with the testing package and
also lets govet work on more logging calls.

R=rsc
CC=golang-dev
https://golang.org/cl/4001048
2011-02-01 12:47:35 -08:00
Jose Luis Vázquez González
865d576702 http: add host patterns
R=bradfitzgo, rsc
CC=golang-dev
https://golang.org/cl/4070043
2011-02-01 13:58:59 -05:00
Russ Cox
8b8cd0e4c4 http: follow relative redirect in Get
Fixes #1431.

R=bradfitz, dangabrad
CC=golang-dev
https://golang.org/cl/4077042
2011-01-20 12:50:27 -05:00
Brad Fitzpatrick
f96c1d076a http: support for relative URLs
R=rsc, adg
CC=golang-dev
https://golang.org/cl/4002041
2011-01-19 15:13:42 -05:00
Clement Skau
49741f23d5 http: fix Content-Range and Content-Length in response
RFC2616 sections 4.4 and 14.16:
  * Cannot use Content-Length with non-identity Transfer-Encoding
  * Content-Range response is "bytes x-y/z" not "x-y/z"

R=rsc
CC=golang-dev
https://golang.org/cl/4018041
2011-01-19 10:05:48 -05:00
Brad Fitzpatrick
b448263f79 http: fix scheme-relative URL parsing; add ParseRequestURL
Also adds some tests for Issue 900 which was the reason
the current URL parsing is broken.  (the previous fix
was wrong)

R=rsc, adg, dangabrad, bradfitzwork
CC=golang-dev
https://golang.org/cl/3910042
2011-01-14 09:10:02 +11:00
Russ Cox
cdb0bbf4d5 http: handle HEAD requests correctly
R=r, r2
CC=golang-dev
https://golang.org/cl/3939042
2011-01-13 14:34:31 -05:00
Russ Cox
cc928b7b6e http: fix text displayed in Redirect
In the case where r.Method == "POST", was
calling Printf with an argument but "" format string,
causing a spurious %!EXTRA(...) message.

Also escape string properly in HTML generation.

R=r
CC=golang-dev
https://golang.org/cl/3923043
2011-01-11 17:15:28 -05:00
Brad Fitzpatrick
d71d08af5a http: permit empty Reason-Phrase in response Status-Line
Fixes #1388.

R=rsc
CC=golang-dev
https://golang.org/cl/3749043
2011-01-05 13:09:38 -05:00
Anthony Martin
d7340d9c20 http: include DEL in the test for unprintable chars
R=adg, rsc
CC=golang-dev
https://golang.org/cl/3631041
2010-12-14 12:26:30 -05:00
Andrew Gerrand
aa9c213e56 http: ServeFile to handle Range header for partial requests
and send Content-Length.

Also includes some testing of the server code.

R=rsc
CC=golang-dev
https://golang.org/cl/2831041
2010-12-10 08:51:13 +11:00
Ryan Hitchman
062406bc64 throughout: simplify two-variable ranges with unused second variable
R=golang-dev, gri
CC=golang-dev
https://golang.org/cl/3529041
2010-12-08 21:36:56 -08:00
Russ Cox
8694959b12 http: fix build
R=dsymonds
TBR=dsymonds
CC=golang-dev
https://golang.org/cl/3425044
2010-12-07 16:20:15 -05:00
Russ Cox
b15c4245c5 crypto/tls: add *Config argument to Dial
Document undocumented exported names.
Allow nil Rand, Time, RootCAs in Config.

Fixes #1248.

R=agl1
CC=golang-dev
https://golang.org/cl/3481042
2010-12-07 16:15:15 -05:00