Fixes #51562
Change-Id: Ia6fe4728b1e3e0cf3a6462be99c1044260cadf31
Reviewed-on: https://go-review.googlesource.com/c/go/+/720822
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
// sends our *Response on, once the *Response itself has been
// populated (even if the body itself is still being
// written to the res.Body, a pipe)
- rw, resc := newPopulateResponseWriter()
+ rw, resc := newPopulateResponseWriter(req)
go func() {
t.fh.ServeHTTP(rw, req)
rw.finish()
return <-resc, nil
}
-func newPopulateResponseWriter() (*populateResponse, <-chan *Response) {
+func newPopulateResponseWriter(req *Request) (*populateResponse, <-chan *Response) {
pr, pw := io.Pipe()
rw := &populateResponse{
ch: make(chan *Response),
Header: make(Header),
Close: true,
Body: pr,
+ Request: req,
},
}
return rw, rw.ch
if string(slurp) != "Bar" {
t.Errorf("for %s, got content %q, want %q", urlstr, string(slurp), "Bar")
}
+ if got := res.Request.URL.String(); got != urlstr {
+ t.Errorf("for %s, Response.Request.URL = %s, want = %s", urlstr, got, urlstr)
+ }
}
const badURL = "file://../no-exist.txt"