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
net/http/httptest: ResponseRecorder does not implement http.ResponseWriter spec correctly #12986
Labels
Milestone
Comments
I will take this one |
CL https://golang.org/cl/16096 mentions this issue. |
I think // trailers returns only trailer headers.
func trailers(h http.Header) http.Header {
res := http.Header{}
for _, keyString := range h["Trailer"] {
for _, key := range strings.Split(keyString, ",") {
key = http.CanonicalHeaderKey(strings.TrimSpace(key))
res[key] = h[key]
}
}
return res
} This will return only trailers. https://play.golang.org/p/348R0WDFOM |
bradfitz
pushed a commit
that referenced
this issue
Oct 20, 2015
* detect Content-Type on ReponseRecorder.Write[String] call if header wasn't written yet, Content-Type header is not set and Transfer-Encoding is not set. * fix typos in serve_test.go Updates #12986 Change-Id: Id2ed8b1994e64657370fed71eb3882d611f76b31 Reviewed-on: https://go-review.googlesource.com/16096 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
I think this can be closed. |
bradfitz
added a commit
that referenced
this issue
Dec 10, 2015
Fixes some failing Google tests when run under Go tip (1.6). Updates #12986 Change-Id: I0ca4d20f6103d10ea9464e45730085401336dada Reviewed-on: https://go-review.googlesource.com/17698 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Nodir Turakulov <nodir@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The documentation for
http.ResponseWriter
specifies certain behaviors for theHeader() Header
and theWrite([]byte) (int, error)
functions that are not being implemented byhttptest.ResponseRecorder
currently. Specifically -Write()
If the Header does not contain a Content-Type line, Write adds a Content-Type set to the result of passing the initial 512 bytes of written data to DetectContentType.I ran into this issue when looking for Content-Type header from ResponseRecorder and looking at the code for ResponseRecorder, did not see an implementation for the spec.
The text was updated successfully, but these errors were encountered: