Skip to content

Commit d0887ba

Browse files
committed
http2: fix bug in earlier CL 123615
I both forgot that this list could contain duplicates, and I had forgot to run the net/http tests against CL 123615 before mailing it, which ended up catching this bug. The diff of this file from the commit before CL 123615 (a45b4ab^ == cffdcf6) to this commit is: https://gist.github.com/bradfitz/0b7abf8fa421515aed9c4d55ce3a1994 ... effectively reverting much of CL 123615 and just moving the 1xx handling down lower. Updates golang/go#26189 (fixes after vendor into std) Updates golang/go#17739 Change-Id: Ib63060b0bb9721883b4b91a983b6e117994faeb9 Reviewed-on: https://go-review.googlesource.com/123675 Run-TryBot: Brad Fitzpatrick <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Andrew Bonventre <[email protected]>
1 parent a1d6821 commit d0887ba

File tree

1 file changed

+15
-20
lines changed

1 file changed

+15
-20
lines changed

http2/transport.go

+15-20
Original file line numberDiff line numberDiff line change
@@ -1763,11 +1763,24 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
17631763
}
17641764

17651765
header := make(http.Header)
1766-
var trailerValue string
1766+
res := &http.Response{
1767+
Proto: "HTTP/2.0",
1768+
ProtoMajor: 2,
1769+
Header: header,
1770+
StatusCode: statusCode,
1771+
Status: status + " " + http.StatusText(statusCode),
1772+
}
17671773
for _, hf := range f.RegularFields() {
17681774
key := http.CanonicalHeaderKey(hf.Name)
17691775
if key == "Trailer" {
1770-
trailerValue = hf.Value
1776+
t := res.Trailer
1777+
if t == nil {
1778+
t = make(http.Header)
1779+
res.Trailer = t
1780+
}
1781+
foreachHeaderElement(hf.Value, func(v string) {
1782+
t[http.CanonicalHeaderKey(v)] = nil
1783+
})
17711784
} else {
17721785
header[key] = append(header[key], hf.Value)
17731786
}
@@ -1794,24 +1807,6 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
17941807
return nil, nil
17951808
}
17961809

1797-
res := &http.Response{
1798-
Proto: "HTTP/2.0",
1799-
ProtoMajor: 2,
1800-
Header: header,
1801-
StatusCode: statusCode,
1802-
Status: status + " " + http.StatusText(statusCode),
1803-
}
1804-
if trailerValue != "" {
1805-
t := res.Trailer
1806-
if t == nil {
1807-
t = make(http.Header)
1808-
res.Trailer = t
1809-
}
1810-
foreachHeaderElement(trailerValue, func(v string) {
1811-
t[http.CanonicalHeaderKey(v)] = nil
1812-
})
1813-
}
1814-
18151810
streamEnded := f.StreamEnded()
18161811
isHead := cs.req.Method == "HEAD"
18171812
if !streamEnded || isHead {

0 commit comments

Comments
 (0)