Example #1
0
func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
	if f.IsAck() {
		return
	}
	f.ForeachSetting(func(s http2.Setting) error {
		if v, ok := f.Value(http2.SettingInitialWindowSize); ok {
			t.mu.Lock()
			defer t.mu.Unlock()
			for _, s := range t.activeStreams {
				s.sendQuotaPool.reset(int(v - t.streamSendQuota))
			}
			t.streamSendQuota = v
		}
		return nil
	})
	t.controlBuf.put(&settings{ack: true})
}
Example #2
0
func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
	if f.IsAck() {
		return
	}
	f.ForeachSetting(func(s http2.Setting) error {
		if v, ok := f.Value(s.ID); ok {
			t.mu.Lock()
			defer t.mu.Unlock()
			switch s.ID {
			case http2.SettingMaxConcurrentStreams:
				t.maxStreams = v
			case http2.SettingInitialWindowSize:
				for _, s := range t.activeStreams {
					// Adjust the sending quota for each s.
					s.sendQuotaPool.reset(int(v - t.streamSendQuota))
				}
				t.streamSendQuota = v
			}
		}
		return nil
	})
	t.controlBuf.put(&settings{ack: true})
}