Commit c7978584 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

http: set method GET on Get() requests

R=adg, bradfitzwork
CC=golang-dev
https://golang.org/cl/4229042
parent 8b8d5e9e
......@@ -171,6 +171,9 @@ func (c *Client) Get(url string) (r *Response, finalURL string, err os.Error) {
}
var req Request
req.Method = "GET"
req.ProtoMajor = 1
req.ProtoMinor = 1
if base == nil {
req.URL, err = ParseURL(url)
} else {
......
......@@ -8,6 +8,7 @@ package http
import (
"io/ioutil"
"os"
"strings"
"testing"
)
......@@ -38,3 +39,25 @@ func TestClientHead(t *testing.T) {
t.Error("Last-Modified header not found.")
}
}
type recordingTransport struct {
req *Request
}
func (t *recordingTransport) Do(req *Request) (resp *Response, err os.Error) {
t.req = req
return nil, os.NewError("dummy impl")
}
func TestGetRequestFormat(t *testing.T) {
tr := &recordingTransport{}
client := &Client{transport: tr}
url := "http://dummy.faketld/"
client.Get(url) // Note: doesn't hit network
if tr.req.Method != "GET" {
t.Fatalf("expected method %q; got %q", "GET", tr.req.Method)
}
if tr.req.URL.String() != url {
t.Fatalf("expected URL %q; got %q", url, tr.req.URL.String())
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment