可以使用httptest来测试HTTP/2吗?

huangapple go评论78阅读模式
英文:

Can httptest be used to test HTTP/2?

问题

我在想是否可以使用httptest包来测试HTTP/2特定功能。有人可以给我指点一些示例吗?

我知道有一个名为h2i的工具,但它是一个交互式工具。我正在寻找一个可以编程的工具。

编辑
我真正想要的是一个工具,例如我可以在服务器端发起推送并在客户端进行测试。所以,使用这个包,我如何访问它默认使用的底层HTTP/2相关内容?

编辑2
在nghttp2源代码中找到了一些示例:
https://github.com/tatsuhiro-t/nghttp2/tree/master/integration-tests

编辑3
对我来说,net/http2包似乎不是直接供任何人使用的。我将尝试使用这个

英文:

I'm wondering if this (httptest) package can be used to test HTTP/2 specific features.
Can anyone point me to some examples maybe?

I'm aware of the tool h2i, but it's an interactive tool.
I'm looking for something which is programmable.

EDIT:
What I'm really looking for is a tool, where for example I can initiate a server push and test it on the client side.
So, using this package, how do I have access to the underlying HTTP/2 stuff it uses by default?

EDIT 2:
Found some examples in the nghttp2 source:
https://github.com/tatsuhiro-t/nghttp2/tree/master/integration-tests

EDIT 3:
For me it looks like that the package net/http2 isn't meant to be used directly by anyone. I'll experiment with this one.

答案1

得分: 1

一般测试提示(避免沮丧)!

不要使用Fiddler进行测试,它会介入你的浏览器和服务器之间,破坏HTTP2连接。

没有HTTP2,就没有推送。

英文:

General testing tip (to avoid frustration)!

Don't use Fiddler to test it, it gets in between your browser and the server and breaks the HTTP2 connection.

No HTTP2 - no push.

答案2

得分: 0

https://github.com/summerwind/h2spec 是一个用于测试服务器实现是否符合 RFC 7540 的 Go 程序。它允许构建单独的 HTTP/2 帧,例如:

settings := http2.Setting{http2.SettingInitialWindowSize, 0}
http2Conn.fr.WriteSettings(settings)

或者

var hp http2.HeadersFrameParam
hp.StreamID = 1
hp.EndStream = false
hp.EndHeaders = true
hp.BlockFragment = http2Conn.EncodeHeader(hdrs)
http2Conn.fr.WriteHeaders(hp)
英文:

https://github.com/summerwind/h2spec is a go program that tests whether a server implementation conforms to RFC 7540. It allows to craft individual HTTP/2 frames such as:

	settings := http2.Setting{http2.SettingInitialWindowSize, 0}
	http2Conn.fr.WriteSettings(settings)

or

	var hp http2.HeadersFrameParam
	hp.StreamID = 1
	hp.EndStream = false
	hp.EndHeaders = true
	hp.BlockFragment = http2Conn.EncodeHeader(hdrs)
	http2Conn.fr.WriteHeaders(hp)

huangapple
  • 本文由 发表于 2016年2月22日 23:46:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/35557891.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定