http2
http2 copied to clipboard
how to enable http2
i tried the example code of client, but the resp.Header.Protocol()
returns HTTP/1.1
could you help me use http2 client?
hc := &fasthttp.HostClient{
Addr: "api.binance.com:443",
}
if err := fasthttp2.ConfigureClient(hc, fasthttp2.ClientOpts{}); err != nil {
log.Printf("%s doesn't support http/2\n", hc.Addr)
}
req := fasthttp.AcquireRequest()
resp := fasthttp.AcquireResponse()
req.SetRequestURI("https://api.binance.com/api/v3/time")
req.Header.SetMethod("GET")
err := hc.Do(req, resp)
if err != nil {
log.Fatalln(err)
}
fmt.Println(resp)
fmt.Printf("%d: %s, %s\n", resp.StatusCode(), resp.Body(), resp.Header.Protocol())