本文整理汇总了Golang中github.com/bradfitz/http2.SettingsFrame类的典型用法代码示例。如果您正苦于以下问题:Golang SettingsFrame类的具体用法?Golang SettingsFrame怎么用?Golang SettingsFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SettingsFrame类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: handleSettings
func (t *http2Client) handleSettings(f *http2.SettingsFrame) {
if v, ok := f.Value(http2.SettingMaxConcurrentStreams); ok {
t.mu.Lock()
t.maxStreams = v
t.mu.Unlock()
}
}
示例2: handleSettings
func (t *http2Server) handleSettings(f *http2.SettingsFrame) {
if f.IsAck() {
return
}
var ss []http2.Setting
f.ForeachSetting(func(s http2.Setting) error {
ss = append(ss, s)
return nil
})
// The settings will be applied once the ack is sent.
t.controlBuf.put(&settings{ack: true, ss: ss})
}
示例3: handleSettings
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})
}
示例4: handleSettings
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 {
switch s.ID {
case http2.SettingMaxConcurrentStreams:
// TODO(zhaoq): This is a hack to avoid significant refactoring of the
// code to deal with the unrealistic int32 overflow. Probably will try
// to find a better way to handle this later.
if v > math.MaxInt32 {
v = math.MaxInt32
}
t.mu.Lock()
reset := t.streamsQuota != nil
if !reset {
t.streamsQuota = newQuotaPool(int(v))
}
ms := t.maxStreams
t.maxStreams = int(v)
t.mu.Unlock()
if reset {
t.streamsQuota.reset(int(v) - ms)
}
case http2.SettingInitialWindowSize:
t.mu.Lock()
for _, s := range t.activeStreams {
// Adjust the sending quota for each s.
s.sendQuotaPool.reset(int(v - t.streamSendQuota))
}
t.streamSendQuota = v
t.mu.Unlock()
}
}
return nil
})
t.controlBuf.put(&settings{ack: true})
}
示例5: handleSettings
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})
}