MCPcopy Create free account
hub / github.com/imroc/req / processSettingsNoWrite

Method processSettingsNoWrite

internal/http2/transport.go:2940–3004  ·  view source on GitHub ↗
(f *SettingsFrame)

Source from the content-addressed store, hash-verified

2938}
2939
2940func (rl *clientConnReadLoop) processSettingsNoWrite(f *SettingsFrame) error {
2941 cc := rl.cc
2942 cc.mu.Lock()
2943 defer cc.mu.Unlock()
2944
2945 if f.IsAck() {
2946 if cc.wantSettingsAck {
2947 cc.wantSettingsAck = false
2948 return nil
2949 }
2950 return ConnectionError(ErrCodeProtocol)
2951 }
2952
2953 var seenMaxConcurrentStreams bool
2954 err := f.ForeachSetting(func(s http2.Setting) error {
2955 switch s.ID {
2956 case http2.SettingMaxFrameSize:
2957 cc.maxFrameSize = s.Val
2958 case http2.SettingMaxConcurrentStreams:
2959 cc.maxConcurrentStreams = s.Val
2960 seenMaxConcurrentStreams = true
2961 case http2.SettingMaxHeaderListSize:
2962 cc.peerMaxHeaderListSize = uint64(s.Val)
2963 case http2.SettingInitialWindowSize:
2964 // Values above the maximum flow-control
2965 // window size of 2^31-1 MUST be treated as a
2966 // connection error (Section 5.4.1) of type
2967 // FLOW_CONTROL_ERROR.
2968 if s.Val > math.MaxInt32 {
2969 return ConnectionError(ErrCodeFlowControl)
2970 }
2971
2972 // Adjust flow control of currently-open
2973 // frames by the difference of the old initial
2974 // window size and this one.
2975 delta := int32(s.Val) - int32(cc.initialWindowSize)
2976 for _, cs := range cc.streams {
2977 cs.flow.add(delta)
2978 }
2979 cc.cond.Broadcast()
2980
2981 cc.initialWindowSize = s.Val
2982 default:
2983 // TODO(bradfitz): handle more settings? SETTINGS_HEADER_TABLE_SIZE probably.
2984 cc.vlogf("Unhandled Setting: %v", s)
2985 }
2986 return nil
2987 })
2988 if err != nil {
2989 return err
2990 }
2991
2992 if !cc.seenSettings {
2993 if !seenMaxConcurrentStreams {
2994 // This was the servers initial SETTINGS frame and it
2995 // didn't contain a MAX_CONCURRENT_STREAMS field so
2996 // increase the number of concurrent streams this
2997 // connection can establish to our default.

Callers 1

processSettingsMethod · 0.95

Calls 7

ConnectionErrorTypeAlias · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
ForeachSettingMethod · 0.80
IsAckMethod · 0.45
addMethod · 0.45
vlogfMethod · 0.45

Tested by

no test coverage detected