aboutsummaryrefslogtreecommitdiff
path: root/src/net/http/client_test.go
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2014-12-29 19:32:07 -0800
committerBrad Fitzpatrick <bradfitz@golang.org>2014-12-30 04:27:17 +0000
commit4b96409aacfb569ac2564240d8aadd668b7c25fa (patch)
tree813f913a6a6ca963d679b16731ee615620c62933 /src/net/http/client_test.go
parent5cc29ab95ecbbf3b7435b30e61d3e49c75c29539 (diff)
downloadgo-4b96409aacfb569ac2564240d8aadd668b7c25fa.tar.xz
net/http: support for setting trailers from a server Handler
We already had client support for trailers, but no way for a server to set them short of hijacking the connection. Fixes #7759 Change-Id: Ic83976437739ec6c1acad5f209ed45e501dbb93a Reviewed-on: https://go-review.googlesource.com/2157 Reviewed-by: Andrew Gerrand <adg@golang.org>
Diffstat (limited to 'src/net/http/client_test.go')
-rw-r--r--src/net/http/client_test.go24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go
index 206ab49711..18645ff00d 100644
--- a/src/net/http/client_test.go
+++ b/src/net/http/client_test.go
@@ -1027,24 +1027,12 @@ func TestClientTrailers(t *testing.T) {
r.Trailer.Get("Client-Trailer-B"))
}
- // TODO: golang.org/issue/7759: there's no way yet for
- // the server to set trailers without hijacking, so do
- // that for now, just to test the client. Later, in
- // Go 1.4, it should be implicit that any mutations
- // to w.Header() after the initial write are the
- // trailers to be sent, if and only if they were
- // previously declared with w.Header().Set("Trailer",
- // ..keys..)
- w.(Flusher).Flush()
- conn, buf, _ := w.(Hijacker).Hijack()
- t := Header{}
- t.Set("Server-Trailer-A", "valuea")
- t.Set("Server-Trailer-C", "valuec") // skipping B
- buf.WriteString("0\r\n") // eof
- t.Write(buf)
- buf.WriteString("\r\n") // end of trailers
- buf.Flush()
- conn.Close()
+ // How handlers set Trailers: declare it ahead of time
+ // with the Trailer header, and then mutate the
+ // Header() of those values later, after the response
+ // has been written (we wrote to w above).
+ w.Header().Set("Server-Trailer-A", "valuea")
+ w.Header().Set("Server-Trailer-C", "valuec") // skipping B
}))
defer ts.Close()