We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
go version go1.6 darwin/amd64
go env
GOARCH="amd64" GOBIN="" GOEXE="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOOS="darwin" GOPATH="/Users/drew/go" GORACE="" GOROOT="/usr/local/opt/go/libexec" GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64" GO15VENDOREXPERIMENT="1" CC="clang" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common" CXX="clang++" CGO_ENABLED="1"
package main import ( "fmt" "net/http" "net/http/httptest" ) const ( header = "Content-Type" value = "application/json" addr = "localhost:8080" ) func TestHandler(w http.ResponseWriter, req *http.Request) { w.Header().Set(header, value) w.WriteHeader(http.StatusOK) } func TestWrongOrderHandler(w http.ResponseWriter, req *http.Request) { w.WriteHeader(http.StatusOK) w.Header().Set(header, value) } func main() { http.HandleFunc("/test", TestHandler) http.HandleFunc("/testWrongOrder", TestWrongOrderHandler) go http.ListenAndServe(addr, nil) checkHeaderValue("/test") checkHeaderValue("/testWrongOrder") } func checkHeaderValue(path string) { req, _ := http.NewRequest("GET", path, nil) rec := httptest.NewRecorder() http.DefaultServeMux.ServeHTTP(rec, req) fmt.Println(path, "(httptest)", rec.HeaderMap[header][0]) resp, _ := http.Get("http://" + addr + path) fmt.Println(path, "(http.Get)", resp.Header[header][0]) }
/test (httptest) application/json /test (http.Get) application/json /testWrongOrder (httptest) text/plain; charset=utf-8 /testWrongOrder (http.Get) text/plain; charset=utf-8
/test (httptest) application/json /test (http.Get) application/json /testWrongOrder (httptest) application/json /testWrongOrder (http.Get) text/plain; charset=utf-8
The text was updated successfully, but these errors were encountered:
Dup of #14531 and/or #8857.
Fixed by c69e686 I believe.
Sorry, something went wrong.
No branches or pull requests
go version
)?go env
)?The text was updated successfully, but these errors were encountered: