client

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithDecoder

func WithDecoder(name string, dec decoder.Decoder) client.Option
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))
Output:

func WithDisableH2

func WithDisableH2() client.Option

WithDisableH2 disables HTTP2 on the transport, only works with http.Transport

func WithProxy

func WithProxy(proxy string) client.Option

WithProxy sets the proxy for a client

func WithProxyFunc

func WithProxyFunc(proxyFunc func(*http.Request) (*url.URL, error)) client.Option

WithProxyFunc sets the proxy getter for a client

func WithSession

func WithSession(options *cookiejar.Options) client.Option

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL