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
063125df
Commit
063125df
authored
Feb 17, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
http: send full URL in proxy requests
Fixes #53. (again) R=agl1 CC=golang-dev
https://golang.org/cl/4167054
parent
f80d0024
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
8 deletions
+34
-8
src/pkg/http/client.go
src/pkg/http/client.go
+13
-7
src/pkg/http/request.go
src/pkg/http/request.go
+21
-1
No files found.
src/pkg/http/client.go
View file @
063125df
...
...
@@ -92,19 +92,25 @@ func send(req *Request) (resp *Response, err os.Error) {
var
proxyURL
*
URL
proxyAuth
:=
""
proxy
:=
os
.
Getenv
(
"HTTP_PROXY"
)
if
proxy
==
""
{
proxy
=
os
.
Getenv
(
"
http_proxy
"
)
}
if
matchNoProxy
(
addr
)
{
proxy
=
""
proxy
:=
""
if
!
matchNoProxy
(
addr
)
{
proxy
=
os
.
Getenv
(
"
HTTP_PROXY
"
)
if
proxy
==
""
{
proxy
=
os
.
Getenv
(
"http_proxy"
)
}
}
if
proxy
!=
""
{
proxyURL
,
err
=
ParseURL
(
proxy
)
proxyURL
,
err
=
Parse
Request
URL
(
proxy
)
if
err
!=
nil
{
return
nil
,
os
.
ErrorString
(
"invalid proxy address"
)
}
if
proxyURL
.
Host
==
""
{
proxyURL
,
err
=
ParseRequestURL
(
"http://"
+
proxy
)
if
err
!=
nil
{
return
nil
,
os
.
ErrorString
(
"invalid proxy address"
)
}
}
addr
=
proxyURL
.
Host
proxyInfo
:=
proxyURL
.
RawUserinfo
if
proxyInfo
!=
""
{
...
...
src/pkg/http/request.go
View file @
063125df
...
...
@@ -184,6 +184,17 @@ const defaultUserAgent = "Go http package"
// If Body is present, Write forces "Transfer-Encoding: chunked" as a header
// and then closes Body when finished sending it.
func
(
req
*
Request
)
Write
(
w
io
.
Writer
)
os
.
Error
{
return
req
.
write
(
w
,
false
)
}
// WriteProxy is like Write but writes the request in the form
// expected by an HTTP proxy. It includes the scheme and host
// name in the URI instead of using a separate Host: header line.
func
(
req
*
Request
)
WriteProxy
(
w
io
.
Writer
)
os
.
Error
{
return
req
.
write
(
w
,
true
)
}
func
(
req
*
Request
)
write
(
w
io
.
Writer
,
usingProxy
bool
)
os
.
Error
{
host
:=
req
.
Host
if
host
==
""
{
host
=
req
.
URL
.
Host
...
...
@@ -197,10 +208,19 @@ func (req *Request) Write(w io.Writer) os.Error {
}
}
if
usingProxy
{
if
uri
==
""
||
uri
[
0
]
!=
'/'
{
uri
=
"/"
+
uri
}
uri
=
req
.
URL
.
Scheme
+
"://"
+
host
+
uri
}
fmt
.
Fprintf
(
w
,
"%s %s HTTP/1.1
\r\n
"
,
valueOrDefault
(
req
.
Method
,
"GET"
),
uri
)
// Header lines
fmt
.
Fprintf
(
w
,
"Host: %s
\r\n
"
,
host
)
if
!
usingProxy
{
fmt
.
Fprintf
(
w
,
"Host: %s
\r\n
"
,
host
)
}
fmt
.
Fprintf
(
w
,
"User-Agent: %s
\r\n
"
,
valueOrDefault
(
req
.
UserAgent
,
defaultUserAgent
))
if
req
.
Referer
!=
""
{
fmt
.
Fprintf
(
w
,
"Referer: %s
\r\n
"
,
req
.
Referer
)
...
...
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