Created
July 12, 2018 20:00
-
-
Save bradfitz/0b7abf8fa421515aed9c4d55ce3a1994 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFrame) (*http.Response, error) { | |
if f.Truncated { | |
return nil, errResponseHeaderListSize | |
@@ -1750,15 +1762,6 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra | |
return nil, errors.New("malformed response from server: malformed non-numeric status pseudo header") | |
} | |
- if statusCode == 100 { | |
- traceGot100Continue(cs.trace) | |
- if cs.on100 != nil { | |
- cs.on100() // forces any write delay timer to fire | |
- } | |
- cs.pastHeaders = false // do it all again | |
- return nil, nil | |
- } | |
- | |
header := make(http.Header) | |
res := &http.Response{ | |
Proto: "HTTP/2.0", | |
@@ -1783,6 +1786,27 @@ func (rl *clientConnReadLoop) handleResponse(cs *clientStream, f *MetaHeadersFra | |
} | |
} | |
+ if statusCode >= 100 && statusCode <= 199 { | |
+ cs.num1xx++ | |
+ const max1xxResponses = 5 // arbitrary bound on number of informational responses, same as net/http | |
+ if cs.num1xx > max1xxResponses { | |
+ return nil, errors.New("http2: too many 1xx informational responses") | |
+ } | |
+ if fn := cs.get1xxTraceFunc(); fn != nil { | |
+ if err := fn(statusCode, textproto.MIMEHeader(header)); err != nil { | |
+ return nil, err | |
+ } | |
+ } | |
+ if statusCode == 100 { | |
+ traceGot100Continue(cs.trace) | |
+ if cs.on100 != nil { | |
+ cs.on100() // forces any write delay timer to fire | |
+ } | |
+ } | |
+ cs.pastHeaders = false // do it all again | |
+ return nil, nil | |
+ } | |
+ | |
streamEnded := f.StreamEnded() | |
isHead := cs.req.Method == "HEAD" | |
if !streamEnded || isHead { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment