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


Golang HeadersFrameParam.Priority方法代码示例

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


在下文中一共展示了HeadersFrameParam.Priority方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: StreamDependenciesTestGroup

func StreamDependenciesTestGroup(ctx *Context) *TestGroup {
	tg := NewTestGroup("5.3.1", "Stream Dependencies")

	tg.AddTestCase(NewTestCase(
		"Sends HEADERS frame that depend on itself",
		"The endpoint MUST treat this as a stream error of type PROTOCOL_ERROR",
		func(ctx *Context) (pass bool, expected []Result, actual Result) {
			http2Conn := CreateHttp2Conn(ctx, true)
			defer http2Conn.conn.Close()

			hdrs := commonHeaderFields(ctx)

			var pp http2.PriorityParam
			pp.StreamDep = 3
			pp.Exclusive = false
			pp.Weight = 255

			var hp http2.HeadersFrameParam
			hp.StreamID = 3
			hp.EndStream = true
			hp.EndHeaders = true
			hp.Priority = pp
			hp.BlockFragment = http2Conn.EncodeHeader(hdrs)
			http2Conn.fr.WriteHeaders(hp)

			actualCodes := []http2.ErrCode{http2.ErrCodeProtocol}
			return TestStreamError(ctx, http2Conn, actualCodes)
		},
	))

	tg.AddTestCase(NewTestCase(
		"Sends PRIORITY frame that depend on itself",
		"The endpoint MUST treat this as a stream error of type PROTOCOL_ERROR",
		func(ctx *Context) (pass bool, expected []Result, actual Result) {
			http2Conn := CreateHttp2Conn(ctx, true)
			defer http2Conn.conn.Close()

			var pp http2.PriorityParam
			pp.StreamDep = 2
			pp.Exclusive = false
			pp.Weight = 255

			http2Conn.fr.WritePriority(2, pp)

			actualCodes := []http2.ErrCode{http2.ErrCodeProtocol}
			return TestStreamError(ctx, http2Conn, actualCodes)
		},
	))

	return tg
}
开发者ID:Lukasa,项目名称:h2spec,代码行数:51,代码来源:5_3.go


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