FAQ
Reviewers: golang-dev1,

Message:
Hello golang-dev@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go/


Description:
net/http: change user agent string

Some IDS somewhere thinks "Go http package" is a virus.
Make it something else for Go 1.1. Dumb but easy.

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

Affected files:
M src/pkg/net/http/header_test.go
M src/pkg/net/http/request.go
M src/pkg/net/http/request_test.go
M src/pkg/net/http/requestwrite_test.go


Index: src/pkg/net/http/header_test.go
===================================================================
--- a/src/pkg/net/http/header_test.go
+++ b/src/pkg/net/http/header_test.go
@@ -178,7 +178,7 @@
"Content-Length": {"123"},
"Content-Type": {"text/plain"},
"Date": {"some date at some time Z"},
- "Server": {"Go http package"},
+ "Server": {"Go 1.1 package http"},
}

var buf bytes.Buffer
Index: src/pkg/net/http/request.go
===================================================================
--- a/src/pkg/net/http/request.go
+++ b/src/pkg/net/http/request.go
@@ -283,7 +283,7 @@
return def
}

-const defaultUserAgent = "Go http package"
+const defaultUserAgent = "Go 1.1 package http"

// Write writes an HTTP/1.1 request -- header and body -- in wire format.
// This method consults the following fields of the request:
Index: src/pkg/net/http/request_test.go
===================================================================
--- a/src/pkg/net/http/request_test.go
+++ b/src/pkg/net/http/request_test.go
@@ -289,7 +289,7 @@
want := []string{
"GET / HTTP/1.1\r\n",
"Host: foo.com\r\n",
- "User-Agent: Go http package\r\n",
+ "User-Agent: Go 1.1 package http\r\n",
"\r\n",
}
if !reflect.DeepEqual(got, want) {
Index: src/pkg/net/http/requestwrite_test.go
===================================================================
--- a/src/pkg/net/http/requestwrite_test.go
+++ b/src/pkg/net/http/requestwrite_test.go
@@ -93,13 +93,13 @@

WantWrite: "GET /search HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Transfer-Encoding: chunked\r\n\r\n" +
chunk("abcdef") + chunk(""),

WantProxy: "GET http://www.google.com/search HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Transfer-Encoding: chunked\r\n\r\n" +
chunk("abcdef") + chunk(""),
},
@@ -123,14 +123,14 @@

WantWrite: "POST /search HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Connection: close\r\n" +
"Transfer-Encoding: chunked\r\n\r\n" +
chunk("abcdef") + chunk(""),

WantProxy: "POST http://www.google.com/search HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Connection: close\r\n" +
"Transfer-Encoding: chunked\r\n\r\n" +
chunk("abcdef") + chunk(""),
@@ -156,7 +156,7 @@

WantWrite: "POST /search HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Connection: close\r\n" +
"Content-Length: 6\r\n" +
"\r\n" +
@@ -164,7 +164,7 @@

WantProxy: "POST http://www.google.com/search HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Connection: close\r\n" +
"Content-Length: 6\r\n" +
"\r\n" +
@@ -187,14 +187,14 @@

WantWrite: "POST / HTTP/1.1\r\n" +
"Host: example.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Content-Length: 6\r\n" +
"\r\n" +
"abcdef",

WantProxy: "POST http://example.com/ HTTP/1.1\r\n" +
"Host: example.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Content-Length: 6\r\n" +
"\r\n" +
"abcdef",
@@ -210,7 +210,7 @@

WantWrite: "GET /search HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"\r\n",
},

@@ -232,13 +232,13 @@
// Also, nginx expects it for POST and PUT.
WantWrite: "POST / HTTP/1.1\r\n" +
"Host: example.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Content-Length: 0\r\n" +
"\r\n",

WantProxy: "POST / HTTP/1.1\r\n" +
"Host: example.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Content-Length: 0\r\n" +
"\r\n",
},
@@ -258,13 +258,13 @@

WantWrite: "POST / HTTP/1.1\r\n" +
"Host: example.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Transfer-Encoding: chunked\r\n\r\n" +
chunk("x") + chunk(""),

WantProxy: "POST / HTTP/1.1\r\n" +
"Host: example.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Transfer-Encoding: chunked\r\n\r\n" +
chunk("x") + chunk(""),
},
@@ -325,7 +325,7 @@

WantWrite: "GET /foo HTTP/1.1\r\n" +
"Host: \r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"X-Foo: X-Bar\r\n\r\n",
},

@@ -351,7 +351,7 @@

WantWrite: "GET /search HTTP/1.1\r\n" +
"Host: \r\n" +
- "User-Agent: Go http package\r\n\r\n",
+ "User-Agent: Go 1.1 package http\r\n\r\n",
},

// Opaque test #1 from golang.org/issue/4860
@@ -370,7 +370,7 @@

WantWrite: "GET /%2F/%2F/ HTTP/1.1\r\n" +
"Host: www.google.com\r\n" +
- "User-Agent: Go http package\r\n\r\n",
+ "User-Agent: Go 1.1 package http\r\n\r\n",
},

// Opaque test #2 from golang.org/issue/4860
@@ -389,7 +389,7 @@

WantWrite: "GET http://y.google.com/%2F/%2F/ HTTP/1.1\r\n" +
"Host: x.google.com\r\n" +
- "User-Agent: Go http package\r\n\r\n",
+ "User-Agent: Go 1.1 package http\r\n\r\n",
},
}

@@ -474,7 +474,7 @@
}
expected := "POST / HTTP/1.1\r\n" +
"Host: foo.com\r\n" +
- "User-Agent: Go http package\r\n" +
+ "User-Agent: Go 1.1 package http\r\n" +
"Transfer-Encoding: chunked\r\n\r\n" +
// TODO: currently we don't buffer before chunking, so we get a
// single "m" chunk before the other chunks, as this was the 1-byte


--

---
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Brad Fitzpatrick at Mar 6, 2013 at 8:38 pm
    use the constant defaultUserAgent in the tests? could be forwarded from
    export_test.go.
    On Wed, Mar 6, 2013 at 12:35 PM, wrote:

    Reviewers: golang-dev1,

    Message:
    Hello golang-dev@googlegroups.com,

    I'd like you to review this change to
    https://code.google.com/p/go/


    Description:
    net/http: change user agent string

    Some IDS somewhere thinks "Go http package" is a virus.
    Make it something else for Go 1.1. Dumb but easy.

    Please review this at https://codereview.appspot.**com/7532043/<https://codereview.appspot.com/7532043/>

    Affected files:
    M src/pkg/net/http/header_test.**go
    M src/pkg/net/http/request.go
    M src/pkg/net/http/request_test.**go
    M src/pkg/net/http/requestwrite_**test.go


    Index: src/pkg/net/http/header_test.**go
    ==============================**==============================**=======
    --- a/src/pkg/net/http/header_**test.go
    +++ b/src/pkg/net/http/header_**test.go
    @@ -178,7 +178,7 @@
    "Content-Length": {"123"},
    "Content-Type": {"text/plain"},
    "Date": {"some date at some time Z"},
    - "Server": {"Go http package"},
    + "Server": {"Go 1.1 package http"},
    }

    var buf bytes.Buffer
    Index: src/pkg/net/http/request.go
    ==============================**==============================**=======
    --- a/src/pkg/net/http/request.go
    +++ b/src/pkg/net/http/request.go
    @@ -283,7 +283,7 @@
    return def
    }

    -const defaultUserAgent = "Go http package"
    +const defaultUserAgent = "Go 1.1 package http"

    // Write writes an HTTP/1.1 request -- header and body -- in wire format.
    // This method consults the following fields of the request:
    Index: src/pkg/net/http/request_test.**go
    ==============================**==============================**=======
    --- a/src/pkg/net/http/request_**test.go
    +++ b/src/pkg/net/http/request_**test.go
    @@ -289,7 +289,7 @@
    want := []string{
    "GET / HTTP/1.1\r\n",
    "Host: foo.com\r\n",
    - "User-Agent: Go http package\r\n",
    + "User-Agent: Go 1.1 package http\r\n",
    "\r\n",
    }
    if !reflect.DeepEqual(got, want) {
    Index: src/pkg/net/http/requestwrite_**test.go
    ==============================**==============================**=======
    --- a/src/pkg/net/http/**requestwrite_test.go
    +++ b/src/pkg/net/http/**requestwrite_test.go
    @@ -93,13 +93,13 @@

    WantWrite: "GET /search HTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Transfer-Encoding: chunked\r\n\r\n" +
    chunk("abcdef") + chunk(""),

    WantProxy: "GET http://www.google.com/searchHTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Transfer-Encoding: chunked\r\n\r\n" +
    chunk("abcdef") + chunk(""),
    },
    @@ -123,14 +123,14 @@

    WantWrite: "POST /search HTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Connection: close\r\n" +
    "Transfer-Encoding: chunked\r\n\r\n" +
    chunk("abcdef") + chunk(""),

    WantProxy: "POST http://www.google.com/searchHTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Connection: close\r\n" +
    "Transfer-Encoding: chunked\r\n\r\n" +
    chunk("abcdef") + chunk(""),
    @@ -156,7 +156,7 @@

    WantWrite: "POST /search HTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Connection: close\r\n" +
    "Content-Length: 6\r\n" +
    "\r\n" +
    @@ -164,7 +164,7 @@

    WantProxy: "POST http://www.google.com/searchHTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Connection: close\r\n" +
    "Content-Length: 6\r\n" +
    "\r\n" +
    @@ -187,14 +187,14 @@

    WantWrite: "POST / HTTP/1.1\r\n" +
    "Host: example.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Content-Length: 6\r\n" +
    "\r\n" +
    "abcdef",

    WantProxy: "POST http://example.com/ HTTP/1.1\r\n" +
    "Host: example.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Content-Length: 6\r\n" +
    "\r\n" +
    "abcdef",
    @@ -210,7 +210,7 @@

    WantWrite: "GET /search HTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "\r\n",
    },

    @@ -232,13 +232,13 @@
    // Also, nginx expects it for POST and PUT.
    WantWrite: "POST / HTTP/1.1\r\n" +
    "Host: example.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Content-Length: 0\r\n" +
    "\r\n",

    WantProxy: "POST / HTTP/1.1\r\n" +
    "Host: example.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Content-Length: 0\r\n" +
    "\r\n",
    },
    @@ -258,13 +258,13 @@

    WantWrite: "POST / HTTP/1.1\r\n" +
    "Host: example.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Transfer-Encoding: chunked\r\n\r\n" +
    chunk("x") + chunk(""),

    WantProxy: "POST / HTTP/1.1\r\n" +
    "Host: example.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Transfer-Encoding: chunked\r\n\r\n" +
    chunk("x") + chunk(""),
    },
    @@ -325,7 +325,7 @@

    WantWrite: "GET /foo HTTP/1.1\r\n" +
    "Host: \r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "X-Foo: X-Bar\r\n\r\n",
    },

    @@ -351,7 +351,7 @@

    WantWrite: "GET /search HTTP/1.1\r\n" +
    "Host: \r\n" +
    - "User-Agent: Go http package\r\n\r\n",
    + "User-Agent: Go 1.1 package http\r\n\r\n",
    },

    // Opaque test #1 from golang.org/issue/4860
    @@ -370,7 +370,7 @@

    WantWrite: "GET /%2F/%2F/ HTTP/1.1\r\n" +
    "Host: www.google.com\r\n" +
    - "User-Agent: Go http package\r\n\r\n",
    + "User-Agent: Go 1.1 package http\r\n\r\n",
    },

    // Opaque test #2 from golang.org/issue/4860
    @@ -389,7 +389,7 @@

    WantWrite: "GET http://y.google.com/%2F/%2F/HTTP/1.1\r\n" +
    "Host: x.google.com\r\n" +
    - "User-Agent: Go http package\r\n\r\n",
    + "User-Agent: Go 1.1 package http\r\n\r\n",
    },
    }

    @@ -474,7 +474,7 @@
    }
    expected := "POST / HTTP/1.1\r\n" +
    "Host: foo.com\r\n" +
    - "User-Agent: Go http package\r\n" +
    + "User-Agent: Go 1.1 package http\r\n" +
    "Transfer-Encoding: chunked\r\n\r\n" +
    // TODO: currently we don't buffer before chunking, so we
    get a
    // single "m" chunk before the other chunks, as this was
    the 1-byte


    --

    ---You received this message because you are subscribed to the Google
    Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-dev+unsubscribe@**googlegroups.com<golang-dev%2Bunsubscribe@googlegroups.com>
    .
    For more options, visit https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
    .

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rsc at Mar 6, 2013 at 8:47 pm
    Hello golang-dev@googlegroups.com, bradfitz@golang.org (cc:
    golang-dev@googlegroups.com),

    Please take another look.


    https://codereview.appspot.com/7532043/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Minux at Mar 6, 2013 at 8:56 pm
    given Go's popularity and Go 1.1's various improvements,
    i expect that virus writers will also upgrade to Go 1.1. ;-)

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Bradfitz at Mar 6, 2013 at 8:57 pm
    LGTM



    https://codereview.appspot.com/7532043/diff/9001/src/pkg/net/http/requestwrite_test.go
    File src/pkg/net/http/requestwrite_test.go (right):

    https://codereview.appspot.com/7532043/diff/9001/src/pkg/net/http/requestwrite_test.go#newcode96
    src/pkg/net/http/requestwrite_test.go:96: "User-Agent: Go 1.1 package
    http\r\n" +
    use the constant all these places too? it's already + concatenation +
    happy

    https://codereview.appspot.com/7532043/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Russ Cox at Mar 6, 2013 at 9:47 pm
    i think it's fine with the concats. it's just a test.

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Rsc at Mar 6, 2013 at 9:48 pm
    *** Submitted as
    https://code.google.com/p/go/source/detail?r=ca2b2e58fb69 ***

    net/http: change user agent string

    Some IDS somewhere thinks "Go http package" is a virus.
    Make it something else for Go 1.1. Dumb but easy.

    R=golang-dev, bradfitz, minux.ma
    CC=golang-dev
    https://codereview.appspot.com/7532043


    https://codereview.appspot.com/7532043/

    --

    ---
    You received this message because you are subscribed to the Google Groups "golang-dev" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-dev+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedMar 6, '13 at 8:35p
activeMar 6, '13 at 9:48p
posts7
users3
websitegolang.org

3 users in discussion

Rsc: 4 posts Bradfitz: 2 posts Minux: 1 post

People

Translate

site design / logo © 2021 Grokbase