Skip to content

how to enable http2 #61

@KazumiLine

Description

@KazumiLine

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())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions