]> Cypherpunks repositories - gostls13.git/commitdiff
net/http: change user agent string
authorRuss Cox <rsc@golang.org>
Wed, 6 Mar 2013 21:48:20 +0000 (16:48 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 6 Mar 2013 21:48:20 +0000 (16:48 -0500)
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://golang.org/cl/7532043

src/pkg/net/http/export_test.go
src/pkg/net/http/header_test.go
src/pkg/net/http/request.go
src/pkg/net/http/request_test.go
src/pkg/net/http/requestwrite_test.go

index a7bca20a07dfa80d2de4a65c0f4760bcff4ed62d..3fc2453267697bee2178e03fbc7c8878e12c4e3b 100644 (file)
@@ -54,3 +54,5 @@ func NewTestTimeoutHandler(handler Handler, ch <-chan time.Time) Handler {
        }
        return &timeoutHandler{handler, f, ""}
 }
+
+var DefaultUserAgent = defaultUserAgent
index 2313b5549345e29e1c07e8c9b6498d5a471c8307..93a904536a8102a968e5310b09d92378aefb05e7 100644 (file)
@@ -178,7 +178,7 @@ var testHeader = Header{
        "Content-Length": {"123"},
        "Content-Type":   {"text/plain"},
        "Date":           {"some date at some time Z"},
-       "Server":         {"Go http package"},
+       "Server":         {DefaultUserAgent},
 }
 
 var buf bytes.Buffer
index 217f35b48331ee8bf06c3885ad58ec74e37bf550..dabb169d1fa3b059bee183dbad84a6c4c92ce89f 100644 (file)
@@ -283,7 +283,7 @@ func valueOrDefault(value, def string) string {
        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 00ad791dedbd08ab3d331f31f7260711e6ca6326..46d622992f16f1d49125ffa11bf42686e95f48d6 100644 (file)
@@ -289,7 +289,7 @@ func TestRequestWriteBufferedWriter(t *testing.T) {
        want := []string{
                "GET / HTTP/1.1\r\n",
                "Host: foo.com\r\n",
-               "User-Agent: Go http package\r\n",
+               "User-Agent: " + DefaultUserAgent + "\r\n",
                "\r\n",
        }
        if !reflect.DeepEqual(got, want) {
index bc637f18b0c2f95356e2ac077e149ce9bef4605e..f78d3882a8f2c297a2a588cd229c3e7d2eae0b09 100644 (file)
@@ -93,13 +93,13 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
                // 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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ var reqWriteTests = []reqWriteTest{
 
                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 @@ func TestRequestWriteClosesBody(t *testing.T) {
        }
        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