Versions in this module Expand all Collapse all v1 v1.0.1 Aug 15, 2024 Changes in this version + const MAX_RETRY_TIMES_FOR_TIMEOUT + var NoRetry = RetryOption + var Retry5XX = RetryOption + var RetryErrResp = RetryOption + type AfterDo struct + func (r AfterDo) Body(b io.Writer) (*Response, error) + func (r AfterDo) DiscardBody() (*Response, error) + func (r AfterDo) JSON(o interface{}) (*Response, error) + func (r AfterDo) RAW() (*http.Response, error) + func (r AfterDo) StreamBody() (io.ReadCloser, *Response, error) + type BasicAuth struct + type DNSCache struct + func NewDNSCache(refreshInterval time.Duration) *DNSCache + type DefaultTracer struct + func NewDefaultTracer(w io.Writer) *DefaultTracer + func (t *DefaultTracer) TraceRequest(req *http.Request) + func (t *DefaultTracer) TraceResponse(r *http.Response) + type HTTPClient struct + func New(ops ...OpOption) *HTTPClient + func (c *HTTPClient) BackendClient() *http.Client + func (c *HTTPClient) BasicAuth(user, password string) *HTTPClient + func (c *HTTPClient) BearerTokenAuth(token string) *HTTPClient + func (c *HTTPClient) Delete(host string, retry ...RetryOption) *Request + func (c *HTTPClient) Get(host string, retry ...RetryOption) *Request + func (c *HTTPClient) Head(host string, retry ...RetryOption) *Request + func (c *HTTPClient) Method(method string, host string, retry ...RetryOption) *Request + func (c *HTTPClient) Patch(host string, retry ...RetryOption) *Request + func (c *HTTPClient) Post(host string, retry ...RetryOption) *Request + func (c *HTTPClient) Put(host string, retry ...RetryOption) *Request + func (c *HTTPClient) TokenAuth(token string) *HTTPClient + type MultipartItem struct + Filename string + Reader io.ReadCloser + type OpOption func(*Option) + func WithAcceptEncoding(ae string) OpOption + func WithClusterDialer(clusterKey string) OpOption + func WithCompleteRedirect() OpOption + func WithCookieJar(jar http.CookieJar) OpOption + func WithDebug(w io.Writer) OpOption + func WithDialContext(dialContext func(ctx context.Context, network, addr string) (net.Conn, error)) OpOption + func WithDialerKeepAlive(keepalive time.Duration) OpOption + func WithDnsCache() OpOption + func WithEnableAutoRetry(enableAutoRetry bool) OpOption + func WithHTTPS() OpOption + func WithHttpsCertFromJSON(certFile, keyFile, caCrt []byte) OpOption + func WithLoadingPrint(desc string) OpOption + func WithPrintUploadProgress(printIntervalSec uint64) OpOption + func WithProxy(proxy string) OpOption + func WithTimeout(dialTimeout, clientTimeout time.Duration) OpOption + func WithTracer(w io.Writer, tracer Tracer) OpOption + type Option struct + type Progress struct + func (pr *Progress) Print() + func (pr *Progress) Write(p []byte) (n int, err error) + type Request struct + func (r *Request) Cookie(v *http.Cookie) *Request + func (r *Request) Do() AfterDo + func (r *Request) FormBody(form url.Values) *Request + func (r *Request) GetUrl() string + func (r *Request) Header(k, v string) *Request + func (r *Request) Headers(hs http.Header) *Request + func (r *Request) JSONBody(o interface{}) *Request + func (r *Request) MultipartFormDataBody(fields map[string]MultipartItem) *Request + func (r *Request) Param(k, v string) *Request + func (r *Request) Params(kvs url.Values) *Request + func (r *Request) Path(path string) *Request + func (r *Request) RawBody(body io.Reader) *Request + func (r *Request) SetParam(k, v string) *Request + type RequestSetter func(request *Request) + func SetCookie(cookie *http.Cookie) RequestSetter + func SetHeaders(headers http.Header) RequestSetter + func SetParams(params url.Values) RequestSetter + type Response struct + func (r *Response) Body() []byte + func (r *Response) Headers() http.Header + func (r *Response) IsBadRequest() bool + func (r *Response) IsConflict() bool + func (r *Response) IsNotfound() bool + func (r *Response) IsOK() bool + func (r *Response) ResponseHeader(key string) string + func (r *Response) StatusCode() int + type RetryFn func() (*http.Response, error) + type RetryFunc func(*http.Request, *http.Response, error) bool + type RetryOption struct + Fns []RetryFunc + Interval int + MaxTime int + type Tracer interface + TraceRequest func(*http.Request) + TraceResponse func(*http.Response)