-
Notifications
You must be signed in to change notification settings - Fork 18k
net/http/httptest: Recorder.Result().Status "OK" instead of "200 OK" #18438
New issue
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
Comments
That's unfortunate we didn't get it right for Go 1.7, but the 1.7 tree is frozen and Go 1.8 is about to be cut, so it's also frozen. Because this isn't a regression from Go 1.7, it doesn't qualify for fixing in Go 1.8 this late in the game. We can consider it during the Go 1.9 cycle, opening early February. |
I wanted to point out that it's a better idea to check |
Agreed. Also, the reason-phrase doesn't even exist in HTTP/2 so we just kinda fake it. |
Thanks @vcabbage - in this case though I'm proxying back a a status-message from a HTTP-like protocol and I want to preserve them in case some human is tracing it. I encountered this minor bug when I was generating test responses using the recorder. Agree, other than creating the initial status string, code should not care about it. |
CL https://golang.org/cl/44000 mentions this issue. |
What version of Go are you using (
go version
)?go version go1.7.1 darwin/amd64
What operating system and processor architecture are you using (
go env
)?GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.7.1/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.7.1/libexec/pkg/tool/darwin_amd64"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/5k/zbrj93rx1cz25qykggmbjjxw0000gp/T/go-build657987326=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
What did you do?
Tests on a HTTP gateway project failed due to differences between the (weakly) documented definition of http.Response.Status and the Status the Recorder result held.
play.golang snippet
bug line in master src
What did you expect to see?
httptest.Recorder.Result().Status == "200 OK"
What did you see instead?
httptest.Recorder.Result().Status == "OK"
The text was updated successfully, but these errors were encountered: