FAQ
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://go.googlecode.com/hg/


Description:
net/http: fix bug parsing http_proxy lacking a protocol

Per the curl man page, the http_proxy configuration can be
of the form:

[protocol://]<host>[:port]

And we had a test that <ip>:<port> worked, but if
the host began with a letter, url.Parse parsed the hostname
as the scheme instead, confusing ProxyFromEnvironment.

Please review this at https://codereview.appspot.com/6875060/

Affected files:
M src/pkg/net/http/transport.go
M src/pkg/net/http/transport_test.go


Index: src/pkg/net/http/transport.go
===================================================================
--- a/src/pkg/net/http/transport.go
+++ b/src/pkg/net/http/transport.go
@@ -90,7 +90,7 @@
return nil, nil
}
proxyURL, err := url.Parse(proxy)
- if err != nil || proxyURL.Scheme == "" {
+ if err != nil || !strings.HasPrefix(proxyURL.Scheme, "http") {
if u, err := url.Parse("http://" + proxy); err == nil {
proxyURL = u
err = nil
Index: src/pkg/net/http/transport_test.go
===================================================================
--- a/src/pkg/net/http/transport_test.go
+++ b/src/pkg/net/http/transport_test.go
@@ -1068,6 +1068,9 @@
wanterr error
}{
{"127.0.0.1:8080", "http://127.0.0.1:8080", nil},
+ {"cache.corp.example.com:1234", "http://cache.corp.example.com:1234",
nil},
+ {"cache.corp.example.com", "http://cache.corp.example.com", nil},
+ {"https://cache.corp.example.com", "https://cache.corp.example.com", nil},
{"http://127.0.0.1:8080", "http://127.0.0.1:8080", nil},
{"https://127.0.0.1:8080", "https://127.0.0.1:8080", nil},
{"", "<nil>", nil},

Search Discussions

  • Russ Cox at Dec 6, 2012 at 3:07 am
    LGTM
  • Bradfitz at Dec 6, 2012 at 3:08 am
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=9a1367cfa93a ***

    net/http: fix bug parsing http_proxy lacking a protocol

    Per the curl man page, the http_proxy configuration can be
    of the form:

    [protocol://]<host>[:port]

    And we had a test that <ip>:<port> worked, but if
    the host began with a letter, url.Parse parsed the hostname
    as the scheme instead, confusing ProxyFromEnvironment.

    R=golang-dev
    CC=golang-dev
    https://codereview.appspot.com/6875060


    https://codereview.appspot.com/6875060/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedDec 4, '12 at 8:57p
activeDec 6, '12 at 3:08a
posts3
users2
websitegolang.org

2 users in discussion

Bradfitz: 2 posts Russ Cox: 1 post

People

Translate

site design / logo © 2021 Grokbase