TestH2c() — gin Function Reference
Architecture documentation for the TestH2c() function in gin_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 319a969f_877b_caaf_c7b7_86a0b29a7a89["TestH2c()"] 5d6e7276_feeb_b8e2_30e8_0ae0827740a5["gin_test.go"] 319a969f_877b_caaf_c7b7_86a0b29a7a89 -->|defined in| 5d6e7276_feeb_b8e2_30e8_0ae0827740a5 style 319a969f_877b_caaf_c7b7_86a0b29a7a89 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
gin_test.go lines 85–121
func TestH2c(t *testing.T) {
ln, err := net.Listen("tcp", localhostIP+":0")
if err != nil {
t.Error(err)
}
r := Default()
r.UseH2C = true
r.GET("/", func(c *Context) {
c.String(200, "<h1>Hello world</h1>")
})
go func() {
err := http.Serve(ln, r.Handler())
if err != nil {
t.Log(err)
}
}()
defer ln.Close()
url := "http://" + ln.Addr().String() + "/"
httpClient := http.Client{
Transport: &http2.Transport{
AllowHTTP: true,
DialTLS: func(netw, addr string, cfg *tls.Config) (net.Conn, error) {
return net.Dial(netw, addr)
},
},
}
res, err := httpClient.Get(url)
if err != nil {
t.Error(err)
}
resp, _ := io.ReadAll(res.Body)
assert.Equal(t, "<h1>Hello world</h1>", string(resp))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestH2c() do?
TestH2c() is a function in the gin codebase, defined in gin_test.go.
Where is TestH2c() defined?
TestH2c() is defined in gin_test.go at line 85.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free