当前位置: 首页>>代码示例>>Golang>>正文


Golang SettingsFrame.Value方法代码示例

本文整理汇总了Golang中github.com/bradfitz/http2.SettingsFrame.Value方法的典型用法代码示例。如果您正苦于以下问题:Golang SettingsFrame.Value方法的具体用法?Golang SettingsFrame.Value怎么用?Golang SettingsFrame.Value使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/bradfitz/http2.SettingsFrame的用法示例。


在下文中一共展示了SettingsFrame.Value方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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()
	}
}
开发者ID:gameduell,项目名称:kythe,代码行数:7,代码来源:http2_client.go

示例2: 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})
}
开发者ID:Xmagicer,项目名称:origin,代码行数:17,代码来源:http2_server.go

示例3: 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})
}
开发者ID:Xmagicer,项目名称:origin,代码行数:39,代码来源:http2_client.go

示例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 {
			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})
}
开发者ID:progrium,项目名称:notary,代码行数:23,代码来源:http2_client.go


注:本文中的github.com/bradfitz/http2.SettingsFrame.Value方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。