Reputation: 1344
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.
Upvotes: 13
Views: 969
Reputation: 146228
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.
Upvotes: 1
Reputation: 5291
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)
Upvotes: 0