]> Cypherpunks repositories - gostls13.git/commitdiff
http/cgi: correctly set request Content-Type
authorEvan Shaw <chickencha@gmail.com>
Fri, 29 Apr 2011 14:04:28 +0000 (07:04 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 29 Apr 2011 14:04:28 +0000 (07:04 -0700)
R=bradfitz
CC=golang-dev
https://golang.org/cl/4433087

src/pkg/http/cgi/child.go
src/pkg/http/cgi/child_test.go

index 760d1179b83ee613ec89946cc6f266908c1e9823..e1ad7ad32211ace01b3c3263d1c129d995e08f6b 100644 (file)
@@ -84,6 +84,10 @@ func RequestFromMap(params map[string]string) (*http.Request, os.Error) {
                r.ContentLength = clen
        }
 
+       if ct := params["CONTENT_TYPE"]; ct != "" {
+               r.Header.Set("Content-Type", ct)
+       }
+
        // Copy "HTTP_FOO_BAR" variables to "Foo-Bar" Headers
        for k, v := range params {
                if !strings.HasPrefix(k, "HTTP_") || skipHeader[k] {
index 87d3f79a0cb843da31fb46fb1909c49c83b89a7a..d12947814e1e799f38c9794c7fb3012424ae8e4c 100644 (file)
@@ -20,6 +20,7 @@ func TestRequest(t *testing.T) {
                "HTTP_FOO_BAR":    "baz",
                "REQUEST_URI":     "/path?a=b",
                "CONTENT_LENGTH":  "123",
+               "CONTENT_TYPE":    "text/xml",
                "HTTPS":           "1",
                "REMOTE_ADDR":     "5.6.7.8",
        }
@@ -37,6 +38,9 @@ func TestRequest(t *testing.T) {
                // Tests that we don't put recognized headers in the map
                t.Errorf("expected User-Agent %q; got %q", e, g)
        }
+       if g, e := req.Header.Get("Content-Type"), "text/xml"; e != g {
+               t.Errorf("expected Content-Type %q; got %q", e, g)
+       }
        if g, e := req.ContentLength, int64(123); e != g {
                t.Errorf("expected ContentLength %d; got %d", e, g)
        }