Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to enable http2 #61

Open
KazumiLine opened this issue Nov 14, 2022 · 0 comments
Open

how to enable http2 #61

KazumiLine opened this issue Nov 14, 2022 · 0 comments

Comments

@KazumiLine
Copy link

KazumiLine commented Nov 14, 2022

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())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant