Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithDecoder ¶
Example ¶
cli, err := requests.NewClient(
WithDecoder("gzip", func(r io.Reader) io.Reader {
gr, err := gzip.NewReader(r)
if err != nil {
// server is sending content-encoding: gzip
// but not returning valid gzipped data
return r
}
return gr
}),
// client.WithDecoder("br", func(r io.Reader) io.Reader { return brotli.NewReader(r) }),
WithDecoder("deflate", func(r io.Reader) io.Reader { return flate.NewReader(r) }),
)
done, resp, err := cli.CtxDo(
context.Background(), request.Get("https://httpbin.org/headers", nil),
)
if err != nil {
panic(err)
}
defer done()
fmt.Println(resp.Header.Get("Date"))
c, err := resp.Body()
fmt.Println(string(c))
func WithDisableH2 ¶
WithDisableH2 disables HTTP2 on the transport, only works with http.Transport
func WithProxyFunc ¶
WithProxyFunc sets the proxy getter for a client
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.