@@ -1763,11 +1763,24 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
1763
1763
}
1764
1764
1765
1765
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
+ }
1767
1773
for _ , hf := range f .RegularFields () {
1768
1774
key := http .CanonicalHeaderKey (hf .Name )
1769
1775
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
+ })
1771
1784
} else {
1772
1785
header [key ] = append (header [key ], hf .Value )
1773
1786
}
@@ -1794,24 +1807,6 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra
1794
1807
return nil , nil
1795
1808
}
1796
1809
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
-
1815
1810
streamEnded := f .StreamEnded ()
1816
1811
isHead := cs .req .Method == "HEAD"
1817
1812
if ! streamEnded || isHead {
0 commit comments