Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
c7978584
Commit
c7978584
authored
Feb 23, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: set method GET on Get() requests
R=adg, bradfitzwork CC=golang-dev
https://golang.org/cl/4229042
parent
8b8d5e9e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
src/pkg/http/client.go
src/pkg/http/client.go
+3
-0
src/pkg/http/client_test.go
src/pkg/http/client_test.go
+23
-0
No files found.
src/pkg/http/client.go
View file @
c7978584
...
...
@@ -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
{
...
...
src/pkg/http/client_test.go
View file @
c7978584
...
...
@@ -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
())
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment