req package - github.com/imroc/req/v3 - Go Packages (original) (raw)
- Constants
- Variables
- func GetClient() *http.Client
- func GetCookies(url string) ([]*http.Cookie, error)
- func GetTLSClientConfig() *tls.Config
- func SetDefaultClient(c *Client)
- type Client
- func AddCommonQueryParam(key, value string) *Client
- func AddCommonQueryParams(key string, values ...string) *Client
- func AddCommonRetryCondition(condition RetryConditionFunc) *Client
- func AddCommonRetryHook(hook RetryHookFunc) *Client
- func C() *Client
- func ClearCookies() *Client
- func DefaultClient() *Client
- func DevMode() *Client
- func DisableAllowGetMethodPayload() *Client
- func DisableAutoDecode() *Client
- func DisableAutoReadResponse() *Client
- func DisableCompression() *Client
- func DisableDebugLog() *Client
- func DisableDumpAll() *Client
- func DisableForceHttpVersion() *Client
- func DisableH2C() *Client
- func DisableInsecureSkipVerify() *Client
- func DisableKeepAlives() *Client
- func DisableTraceAll() *Client
- func EnableAllowGetMethodPayload() *Client
- func EnableAutoDecode() *Client
- func EnableAutoReadResponse() *Client
- func EnableCompression() *Client
- func EnableDebugLog() *Client
- func EnableDumpAll() *Client
- func EnableDumpAllAsync() *Client
- func EnableDumpAllTo(output io.Writer) *Client
- func EnableDumpAllToFile(filename string) *Client
- func EnableDumpAllWithoutBody() *Client
- func EnableDumpAllWithoutHeader() *Client
- func EnableDumpAllWithoutRequest() *Client
- func EnableDumpAllWithoutRequestBody() *Client
- func EnableDumpAllWithoutResponse() *Client
- func EnableDumpAllWithoutResponseBody() *Client
- func EnableDumpEachRequest() *Client
- func EnableDumpEachRequestWithoutBody() *Client
- func EnableDumpEachRequestWithoutHeader() *Client
- func EnableDumpEachRequestWithoutRequest() *Client
- func EnableDumpEachRequestWithoutRequestBody() *Client
- func EnableDumpEachRequestWithoutResponse() *Client
- func EnableDumpEachRequestWithoutResponseBody() *Client
- func EnableForceHTTP1() *Client
- func EnableForceHTTP2() *Client
- func EnableForceHTTP3() *Client
- func EnableH2C() *Client
- func EnableHTTP3() *Client
- func EnableInsecureSkipVerify() *Client
- func EnableKeepAlives() *Client
- func EnableTraceAll() *Client
- func ImpersonateChrome() *Client
- func ImpersonateFirefox() *Client
- func ImpersonateSafari() *Client
- func NewClient() *Client
- func OnAfterResponse(m ResponseMiddleware) *Client
- func OnBeforeRequest(m RequestMiddleware) *Client
- func SetAutoDecodeAllContentType() *Client
- func SetAutoDecodeContentType(contentTypes ...string) *Client
- func SetAutoDecodeContentTypeFunc(fn func(contentType string) bool) *Client
- func SetBaseURL(u string) *Client
- func SetCertFromFile(certFile, keyFile string) *Client
- func SetCerts(certs ...tls.Certificate) *Client
- func SetCommonBasicAuth(username, password string) *Client
- func SetCommonBearerAuthToken(token string) *Client
- func SetCommonContentType(ct string) *Client
- func SetCommonCookies(cookies ...*http.Cookie) *Client
- func SetCommonDigestAuth(username, password string) *Client
- func SetCommonDumpOptions(opt *DumpOptions) *Client
- func SetCommonError(err any) *Clientdeprecated
- func SetCommonErrorResult(err any) *Client
- func SetCommonFormData(data map[string]string) *Client
- func SetCommonFormDataFromValues(data url.Values) *Client
- func SetCommonHeader(key, value string) *Client
- func SetCommonHeaderOrder(keys ...string) *Client
- func SetCommonHeaders(hdrs map[string]string) *Client
- func SetCommonPathParam(key, value string) *Client
- func SetCommonPathParams(pathParams map[string]string) *Client
- func SetCommonPseudoHeaderOder(keys ...string) *Client
- func SetCommonQueryParam(key, value string) *Client
- func SetCommonQueryParams(params map[string]string) *Client
- func SetCommonQueryParamsFromStruct(v any) *Client
- func SetCommonQueryParamsFromValues(params url.Values) *Client
- func SetCommonQueryString(query string) *Client
- func SetCommonRetryBackoffInterval(min, max time.Duration) *Client
- func SetCommonRetryCondition(condition RetryConditionFunc) *Client
- func SetCommonRetryCount(count int) *Client
- func SetCommonRetryFixedInterval(interval time.Duration) *Client
- func SetCommonRetryHook(hook RetryHookFunc) *Client
- func SetCommonRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Client
- func SetCookieJar(jar http.CookieJar) *Client
- func SetDial(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Client
- func SetDialTLS(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Client
- func SetHTTP2ConnectionFlow(flow uint32) *Client
- func SetHTTP2HeaderPriority(priority http2.PriorityParam) *Client
- func SetHTTP2MaxHeaderListSize(max uint32) *Client
- func SetHTTP2PingTimeout(timeout time.Duration) *Client
- func SetHTTP2PriorityFrames(frames ...http2.PriorityFrame) *Client
- func SetHTTP2ReadIdleTimeout(timeout time.Duration) *Client
- func SetHTTP2SettingsFrame(settings ...http2.Setting) *Client
- func SetHTTP2StrictMaxConcurrentStreams(strict bool) *Client
- func SetHTTP2WriteByteTimeout(timeout time.Duration) *Client
- func SetJsonMarshal(fn func(v any) ([]byte, error)) *Client
- func SetJsonUnmarshal(fn func(data []byte, v any) error) *Client
- func SetLogger(log Logger) *Client
- func SetMultipartBoundaryFunc(fn func() string) *Client
- func SetOutputDirectory(dir string) *Client
- func SetProxy(proxy func(*http.Request) (*url.URL, error)) *Client
- func SetProxyURL(proxyUrl string) *Client
- func SetRedirectPolicy(policies ...RedirectPolicy) *Client
- func SetResponseBodyTransformer(...) *Client
- func SetResultStateCheckFunc(fn func(resp *Response) ResultState) *Client
- func SetRootCertFromString(pemContent string) *Client
- func SetRootCertsFromFile(pemFiles ...string) *Client
- func SetScheme(scheme string) *Client
- func SetTLSClientConfig(conf *tls.Config) *Client
- func SetTLSFingerprint(clientHelloID utls.ClientHelloID) *Client
- func SetTLSFingerprint360() *Client
- func SetTLSFingerprintAndroid() *Client
- func SetTLSFingerprintChrome() *Client
- func SetTLSFingerprintEdge() *Client
- func SetTLSFingerprintFirefox() *Client
- func SetTLSFingerprintIOS() *Client
- func SetTLSFingerprintQQ() *Client
- func SetTLSFingerprintRandomized() *Client
- func SetTLSFingerprintSafari() *Client
- func SetTLSHandshakeTimeout(timeout time.Duration) *Client
- func SetTimeout(d time.Duration) *Client
- func SetUnixSocket(file string) *Client
- func SetUserAgent(userAgent string) *Client
- func SetXmlMarshal(fn func(v any) ([]byte, error)) *Client
- func SetXmlUnmarshal(fn func(data []byte, v any) error) *Client
- func WrapRoundTrip(wrappers ...RoundTripWrapper) *Client
- func WrapRoundTripFunc(funcs ...RoundTripWrapperFunc) *Client
- func (c *Client) AddCommonQueryParam(key, value string) *Client
- func (c *Client) AddCommonQueryParams(key string, values ...string) *Client
- func (c *Client) AddCommonRetryCondition(condition RetryConditionFunc) *Client
- func (c *Client) AddCommonRetryHook(hook RetryHookFunc) *Client
- func (c *Client) ClearCookies() *Client
- func (c *Client) Clone() *Client
- func (c *Client) Delete(url ...string) *Request
- func (c *Client) DevMode() *Client
- func (c *Client) DisableAllowGetMethodPayload() *Client
- func (c *Client) DisableAutoDecode() *Client
- func (c *Client) DisableAutoDecompress() *Client
- func (c *Client) DisableAutoReadResponse() *Client
- func (c *Client) DisableCompression() *Client
- func (c *Client) DisableDebugLog() *Client
- func (c *Client) DisableDumpAll() *Client
- func (c *Client) DisableForceHttpVersion() *Client
- func (c *Client) DisableH2C() *Client
- func (c *Client) DisableHTTP3() *Client
- func (c *Client) DisableInsecureSkipVerify() *Client
- func (c *Client) DisableKeepAlives() *Client
- func (c *Client) DisableTraceAll() *Client
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) EnableAllowGetMethodPayload() *Client
- func (c *Client) EnableAutoDecode() *Client
- func (c *Client) EnableAutoDecompress() *Client
- func (c *Client) EnableAutoReadResponse() *Client
- func (c *Client) EnableCompression() *Client
- func (c *Client) EnableDebugLog() *Client
- func (c *Client) EnableDumpAll() *Client
- func (c *Client) EnableDumpAllAsync() *Client
- func (c *Client) EnableDumpAllTo(output io.Writer) *Client
- func (c *Client) EnableDumpAllToFile(filename string) *Client
- func (c *Client) EnableDumpAllWithoutBody() *Client
- func (c *Client) EnableDumpAllWithoutHeader() *Client
- func (c *Client) EnableDumpAllWithoutRequest() *Client
- func (c *Client) EnableDumpAllWithoutRequestBody() *Client
- func (c *Client) EnableDumpAllWithoutResponse() *Client
- func (c *Client) EnableDumpAllWithoutResponseBody() *Client
- func (c *Client) EnableDumpEachRequest() *Client
- func (c *Client) EnableDumpEachRequestWithoutBody() *Client
- func (c *Client) EnableDumpEachRequestWithoutHeader() *Client
- func (c *Client) EnableDumpEachRequestWithoutRequest() *Client
- func (c *Client) EnableDumpEachRequestWithoutRequestBody() *Client
- func (c *Client) EnableDumpEachRequestWithoutResponse() *Client
- func (c *Client) EnableDumpEachRequestWithoutResponseBody() *Client
- func (c *Client) EnableForceHTTP1() *Client
- func (c *Client) EnableForceHTTP2() *Client
- func (c *Client) EnableForceHTTP3() *Client
- func (c *Client) EnableH2C() *Client
- func (c *Client) EnableHTTP3() *Client
- func (c *Client) EnableInsecureSkipVerify() *Client
- func (c *Client) EnableKeepAlives() *Client
- func (c *Client) EnableTraceAll() *Client
- func (c *Client) Get(url ...string) *Request
- func (c *Client) GetClient() *http.Client
- func (c *Client) GetCookies(url string) ([]*http.Cookie, error)
- func (c *Client) GetLogger() Logger
- func (c *Client) GetTLSClientConfig() *tls.Config
- func (c *Client) GetTransport() *Transport
- func (c *Client) Head(url ...string) *Request
- func (c *Client) ImpersonateChrome() *Client
- func (c *Client) ImpersonateFirefox() *Client
- func (c *Client) ImpersonateSafari() *Client
- func (c *Client) NewParallelDownload(url string) *ParallelDownload
- func (c *Client) NewRequest() *Request
- func (c *Client) OnAfterResponse(m ResponseMiddleware) *Client
- func (c *Client) OnBeforeRequest(m RequestMiddleware) *Client
- func (c *Client) OnError(hook ErrorHook) *Client
- func (c *Client) Options(url ...string) *Request
- func (c *Client) Patch(url ...string) *Request
- func (c *Client) Post(url ...string) *Request
- func (c *Client) Put(url ...string) *Request
- func (c *Client) R() *Request
- func (c *Client) SetAutoDecodeAllContentType() *Client
- func (c *Client) SetAutoDecodeContentType(contentTypes ...string) *Client
- func (c *Client) SetAutoDecodeContentTypeFunc(fn func(contentType string) bool) *Client
- func (c *Client) SetBaseURL(u string) *Client
- func (c *Client) SetCertFromFile(certFile, keyFile string) *Client
- func (c *Client) SetCerts(certs ...tls.Certificate) *Client
- func (c *Client) SetCommonBasicAuth(username, password string) *Client
- func (c *Client) SetCommonBearerAuthToken(token string) *Client
- func (c *Client) SetCommonContentType(ct string) *Client
- func (c *Client) SetCommonCookies(cookies ...*http.Cookie) *Client
- func (c *Client) SetCommonDigestAuth(username, password string) *Client
- func (c *Client) SetCommonDumpOptions(opt *DumpOptions) *Client
- func (c *Client) SetCommonError(err any) *Clientdeprecated
- func (c *Client) SetCommonErrorResult(err any) *Client
- func (c *Client) SetCommonFormData(data map[string]string) *Client
- func (c *Client) SetCommonFormDataFromValues(data urlpkg.Values) *Client
- func (c *Client) SetCommonHeader(key, value string) *Client
- func (c *Client) SetCommonHeaderNonCanonical(key, value string) *Client
- func (c *Client) SetCommonHeaderOrder(keys ...string) *Client
- func (c *Client) SetCommonHeaders(hdrs map[string]string) *Client
- func (c *Client) SetCommonHeadersNonCanonical(hdrs map[string]string) *Client
- func (c *Client) SetCommonPathParam(key, value string) *Client
- func (c *Client) SetCommonPathParams(pathParams map[string]string) *Client
- func (c *Client) SetCommonPseudoHeaderOder(keys ...string) *Client
- func (c *Client) SetCommonQueryParam(key, value string) *Client
- func (c *Client) SetCommonQueryParams(params map[string]string) *Client
- func (c *Client) SetCommonQueryParamsFromStruct(v any) *Client
- func (c *Client) SetCommonQueryParamsFromValues(params urlpkg.Values) *Client
- func (c *Client) SetCommonQueryString(query string) *Client
- func (c *Client) SetCommonRetryBackoffInterval(min, max time.Duration) *Client
- func (c *Client) SetCommonRetryCondition(condition RetryConditionFunc) *Client
- func (c *Client) SetCommonRetryCount(count int) *Client
- func (c *Client) SetCommonRetryFixedInterval(interval time.Duration) *Client
- func (c *Client) SetCommonRetryHook(hook RetryHookFunc) *Client
- func (c *Client) SetCommonRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Client
- func (c *Client) SetCookieJar(jar http.CookieJar) *Client
- func (c *Client) SetCookieJarFactory(factory func() *cookiejar.Jar) *Client
- func (c *Client) SetDial(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Client
- func (c *Client) SetDialTLS(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Client
- func (c *Client) SetHTTP2ConnectionFlow(flow uint32) *Client
- func (c *Client) SetHTTP2HeaderPriority(priority http2.PriorityParam) *Client
- func (c *Client) SetHTTP2MaxHeaderListSize(max uint32) *Client
- func (c *Client) SetHTTP2PingTimeout(timeout time.Duration) *Client
- func (c *Client) SetHTTP2PriorityFrames(frames ...http2.PriorityFrame) *Client
- func (c *Client) SetHTTP2ReadIdleTimeout(timeout time.Duration) *Client
- func (c *Client) SetHTTP2SettingsFrame(settings ...http2.Setting) *Client
- func (c *Client) SetHTTP2StrictMaxConcurrentStreams(strict bool) *Client
- func (c *Client) SetHTTP2WriteByteTimeout(timeout time.Duration) *Client
- func (c *Client) SetJsonMarshal(fn func(v any) ([]byte, error)) *Client
- func (c *Client) SetJsonUnmarshal(fn func(data []byte, v any) error) *Client
- func (c *Client) SetLogger(log Logger) *Client
- func (c *Client) SetMultipartBoundaryFunc(fn func() string) *Client
- func (c *Client) SetOutputDirectory(dir string) *Client
- func (c *Client) SetProxy(proxy func(*http.Request) (*urlpkg.URL, error)) *Client
- func (c *Client) SetProxyURL(proxyUrl string) *Client
- func (c *Client) SetRedirectPolicy(policies ...RedirectPolicy) *Client
- func (c *Client) SetResponseBodyTransformer(...) *Client
- func (c *Client) SetResultStateCheckFunc(fn func(resp *Response) ResultState) *Client
- func (c *Client) SetRootCertFromString(pemContent string) *Client
- func (c *Client) SetRootCertsFromFile(pemFiles ...string) *Client
- func (c *Client) SetScheme(scheme string) *Client
- func (c *Client) SetTLSClientConfig(conf *tls.Config) *Client
- func (c *Client) SetTLSFingerprint(clientHelloID utls.ClientHelloID) *Client
- func (c *Client) SetTLSFingerprint360() *Client
- func (c *Client) SetTLSFingerprintAndroid() *Client
- func (c *Client) SetTLSFingerprintChrome() *Client
- func (c *Client) SetTLSFingerprintEdge() *Client
- func (c *Client) SetTLSFingerprintFirefox() *Client
- func (c *Client) SetTLSFingerprintIOS() *Client
- func (c *Client) SetTLSFingerprintQQ() *Client
- func (c *Client) SetTLSFingerprintRandomized() *Client
- func (c *Client) SetTLSFingerprintSafari() *Client
- func (c *Client) SetTLSHandshake(...) *Client
- func (c *Client) SetTLSHandshakeTimeout(timeout time.Duration) *Client
- func (c *Client) SetTimeout(d time.Duration) *Client
- func (c *Client) SetUnixSocket(file string) *Client
- func (c *Client) SetUserAgent(userAgent string) *Client
- func (c *Client) SetXmlMarshal(fn func(v any) ([]byte, error)) *Client
- func (c *Client) SetXmlUnmarshal(fn func(data []byte, v any) error) *Client
- func (c *Client) WrapRoundTrip(wrappers ...RoundTripWrapper) *Client
- func (c *Client) WrapRoundTripFunc(funcs ...RoundTripWrapperFunc) *Client
- type ContentDisposition
- type DownloadCallback
- type DownloadInfo
- type DumpOptions
- type ErrorHook
- type FileUpload
- type GetContentFunc
- type GetRetryIntervalFunc
- type HttpRoundTripFunc
- type HttpRoundTripWrapper
- type HttpRoundTripWrapperFunc
- type Logger
- type ParallelDownload
- func (pd *ParallelDownload) Do(ctx ...context.Context) error
- func (pd *ParallelDownload) SetConcurrency(concurrency int) *ParallelDownload
- func (pd *ParallelDownload) SetFileMode(perm os.FileMode) *ParallelDownload
- func (pd *ParallelDownload) SetOutput(output io.Writer) *ParallelDownload
- func (pd *ParallelDownload) SetOutputFile(filename string) *ParallelDownload
- func (pd *ParallelDownload) SetSegmentSize(segmentSize int64) *ParallelDownload
- func (pd *ParallelDownload) SetTempRootDir(tempRootDir string) *ParallelDownload
- type RedirectPolicy
- func AllowedDomainRedirectPolicy(hosts ...string) RedirectPolicy
- func AllowedHostRedirectPolicy(hosts ...string) RedirectPolicy
- func AlwaysCopyHeaderRedirectPolicy(headers ...string) RedirectPolicy
- func DefaultRedirectPolicy() RedirectPolicy
- func MaxRedirectPolicy(noOfRedirect int) RedirectPolicy
- func NoRedirectPolicy() RedirectPolicy
- func SameDomainRedirectPolicy() RedirectPolicy
- func SameHostRedirectPolicy() RedirectPolicy
- type Request
- func AddQueryParam(key, value string) *Request
- func AddQueryParams(key string, values ...string) *Request
- func AddRetryCondition(condition RetryConditionFunc) *Request
- func AddRetryHook(hook RetryHookFunc) *Request
- func DisableForceChunkedEncoding() *Request
- func DisableForceMultipart() *Request
- func DisableTrace() *Request
- func EnableCloseConnection() *Request
- func EnableDump() *Request
- func EnableDumpTo(output io.Writer) *Request
- func EnableDumpToFile(filename string) *Request
- func EnableDumpWithoutBody() *Request
- func EnableDumpWithoutHeader() *Request
- func EnableDumpWithoutRequest() *Request
- func EnableDumpWithoutRequestBody() *Request
- func EnableDumpWithoutResponse() *Request
- func EnableDumpWithoutResponseBody() *Request
- func EnableForceChunkedEncoding() *Request
- func EnableForceMultipart() *Request
- func EnableTrace() *Request
- func NewRequest() *Request
- func R() *Request
- func SetBasicAuth(username, password string) *Request
- func SetBearerAuthToken(token string) *Request
- func SetBody(body any) *Request
- func SetBodyBytes(body []byte) *Request
- func SetBodyJsonBytes(body []byte) *Request
- func SetBodyJsonMarshal(v any) *Request
- func SetBodyJsonString(body string) *Request
- func SetBodyString(body string) *Request
- func SetBodyXmlBytes(body []byte) *Request
- func SetBodyXmlMarshal(v any) *Request
- func SetBodyXmlString(body string) *Request
- func SetContentType(contentType string) *Request
- func SetContext(ctx context.Context) *Request
- func SetCookies(cookies ...*http.Cookie) *Request
- func SetDigestAuth(username, password string) *Request
- func SetDownloadCallback(callback DownloadCallback) *Request
- func SetDownloadCallbackWithInterval(callback DownloadCallback, minInterval time.Duration) *Request
- func SetDumpOptions(opt *DumpOptions) *Request
- func SetError(error any) *Requestdeprecated
- func SetErrorResult(error any) *Request
- func SetFile(paramName, filePath string) *Request
- func SetFileBytes(paramName, filename string, content []byte) *Request
- func SetFileReader(paramName, filePath string, reader io.Reader) *Request
- func SetFileUpload(f ...FileUpload) *Request
- func SetFiles(files map[string]string) *Request
- func SetFormData(data map[string]string) *Request
- func SetFormDataAnyType(data map[string]any) *Request
- func SetFormDataFromValues(data url.Values) *Request
- func SetHeader(key, value string) *Request
- func SetHeaderOrder(keys ...string) *Request
- func SetHeaders(hdrs map[string]string) *Request
- func SetOrderedFormData(kvs ...string) *Request
- func SetOutput(output io.Writer) *Request
- func SetOutputFile(file string) *Request
- func SetPathParam(key, value string) *Request
- func SetPathParams(params map[string]string) *Request
- func SetPseudoHeaderOrder(keys ...string) *Request
- func SetQueryParam(key, value string) *Request
- func SetQueryParams(params map[string]string) *Request
- func SetQueryParamsAnyType(params map[string]any) *Request
- func SetQueryParamsFromStruct(v any) *Request
- func SetQueryParamsFromValues(params url.Values) *Request
- func SetQueryString(query string) *Request
- func SetResult(result any) *Requestdeprecated
- func SetRetryBackoffInterval(min, max time.Duration) *Request
- func SetRetryCondition(condition RetryConditionFunc) *Request
- func SetRetryCount(count int) *Request
- func SetRetryFixedInterval(interval time.Duration) *Request
- func SetRetryHook(hook RetryHookFunc) *Request
- func SetRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Request
- func SetSuccessResult(result any) *Request
- func SetURL(url string) *Request
- func SetUploadCallback(callback UploadCallback) *Request
- func SetUploadCallbackWithInterval(callback UploadCallback, minInterval time.Duration) *Request
- func (r *Request) AddQueryParam(key, value string) *Request
- func (r *Request) AddQueryParams(key string, values ...string) *Request
- func (r *Request) AddRetryCondition(condition RetryConditionFunc) *Request
- func (r *Request) AddRetryHook(hook RetryHookFunc) *Request
- func (r *Request) Context() context.Context
- func (r *Request) Delete(url string) (*Response, error)
- func (r *Request) DisableAutoReadResponse() *Request
- func (r *Request) DisableForceChunkedEncoding() *Request
- func (r *Request) DisableForceMultipart() *Request
- func (r *Request) DisableTrace() *Request
- func (r *Request) Do(ctx ...context.Context) *Response
- func (r *Request) EnableAutoReadResponse() *Request
- func (r *Request) EnableCloseConnection() *Request
- func (r *Request) EnableDump() *Request
- func (r *Request) EnableDumpTo(output io.Writer) *Request
- func (r *Request) EnableDumpToFile(filename string) *Request
- func (r *Request) EnableDumpWithoutBody() *Request
- func (r *Request) EnableDumpWithoutHeader() *Request
- func (r *Request) EnableDumpWithoutRequest() *Request
- func (r *Request) EnableDumpWithoutRequestBody() *Request
- func (r *Request) EnableDumpWithoutResponse() *Request
- func (r *Request) EnableDumpWithoutResponseBody() *Request
- func (r *Request) EnableForceChunkedEncoding() *Request
- func (r *Request) EnableForceMultipart() *Request
- func (r *Request) EnableTrace() *Request
- func (r *Request) Get(url string) (*Response, error)
- func (r *Request) GetClient() *Client
- func (r *Request) GetContextData(key any) any
- func (r *Request) Head(url string) (*Response, error)
- func (r *Request) HeaderToString() string
- func (r *Request) MustDelete(url string) *Response
- func (r *Request) MustGet(url string) *Response
- func (r *Request) MustHead(url string) *Response
- func (r *Request) MustOptions(url string) *Response
- func (r *Request) MustPatch(url string) *Response
- func (r *Request) MustPost(url string) *Response
- func (r *Request) MustPut(url string) *Response
- func (r *Request) OnAfterResponse(m ResponseMiddleware) *Request
- func (r *Request) Options(url string) (*Response, error)
- func (r *Request) Patch(url string) (*Response, error)
- func (r *Request) Post(url string) (*Response, error)
- func (r *Request) Put(url string) (*Response, error)
- func (r *Request) Send(method, url string) (*Response, error)
- func (r *Request) SetBasicAuth(username, password string) *Request
- func (r *Request) SetBearerAuthToken(token string) *Request
- func (r *Request) SetBody(body any) *Request
- func (r *Request) SetBodyBytes(body []byte) *Request
- func (r *Request) SetBodyJsonBytes(body []byte) *Request
- func (r *Request) SetBodyJsonMarshal(v any) *Request
- func (r *Request) SetBodyJsonString(body string) *Request
- func (r *Request) SetBodyString(body string) *Request
- func (r *Request) SetBodyXmlBytes(body []byte) *Request
- func (r *Request) SetBodyXmlMarshal(v any) *Request
- func (r *Request) SetBodyXmlString(body string) *Request
- func (r *Request) SetClient(client *Client) *Request
- func (r *Request) SetContentType(contentType string) *Request
- func (r *Request) SetContext(ctx context.Context) *Request
- func (r *Request) SetContextData(key, val any) *Request
- func (r *Request) SetCookies(cookies ...*http.Cookie) *Request
- func (r *Request) SetDigestAuth(username, password string) *Requestdeprecated
- func (r *Request) SetDownloadCallback(callback DownloadCallback) *Request
- func (r *Request) SetDownloadCallbackWithInterval(callback DownloadCallback, minInterval time.Duration) *Request
- func (r *Request) SetDumpOptions(opt *DumpOptions) *Request
- func (r *Request) SetError(err any) *Requestdeprecated
- func (r *Request) SetErrorResult(err any) *Request
- func (r *Request) SetFile(paramName, filePath string) *Request
- func (r *Request) SetFileBytes(paramName, filename string, content []byte) *Request
- func (r *Request) SetFileReader(paramName, filename string, reader io.Reader) *Request
- func (r *Request) SetFileUpload(uploads ...FileUpload) *Request
- func (r *Request) SetFiles(files map[string]string) *Request
- func (r *Request) SetFormData(data map[string]string) *Request
- func (r *Request) SetFormDataAnyType(data map[string]any) *Request
- func (r *Request) SetFormDataFromValues(data urlpkg.Values) *Request
- func (r *Request) SetHeader(key, value string) *Request
- func (r *Request) SetHeaderNonCanonical(key, value string) *Request
- func (r *Request) SetHeaderOrder(keys ...string) *Request
- func (r *Request) SetHeaders(hdrs map[string]string) *Request
- func (r *Request) SetHeadersNonCanonical(hdrs map[string]string) *Request
- func (r *Request) SetOrderedFormData(kvs ...string) *Request
- func (r *Request) SetOutput(output io.Writer) *Request
- func (r *Request) SetOutputFile(file string) *Request
- func (r *Request) SetPathParam(key, value string) *Request
- func (r *Request) SetPathParams(params map[string]string) *Request
- func (r *Request) SetPseudoHeaderOrder(keys ...string) *Request
- func (r *Request) SetQueryParam(key, value string) *Request
- func (r *Request) SetQueryParams(params map[string]string) *Request
- func (r *Request) SetQueryParamsAnyType(params map[string]any) *Request
- func (r *Request) SetQueryParamsFromStruct(v any) *Request
- func (r *Request) SetQueryParamsFromValues(params urlpkg.Values) *Request
- func (r *Request) SetQueryString(query string) *Request
- func (r *Request) SetResult(result any) *Requestdeprecated
- func (r *Request) SetRetryBackoffInterval(min, max time.Duration) *Request
- func (r *Request) SetRetryCondition(condition RetryConditionFunc) *Request
- func (r *Request) SetRetryCount(count int) *Request
- func (r *Request) SetRetryFixedInterval(interval time.Duration) *Request
- func (r *Request) SetRetryHook(hook RetryHookFunc) *Request
- func (r *Request) SetRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Request
- func (r *Request) SetSuccessResult(result any) *Request
- func (r *Request) SetURL(url string) *Request
- func (r *Request) SetUploadCallback(callback UploadCallback) *Request
- func (r *Request) SetUploadCallbackWithInterval(callback UploadCallback, minInterval time.Duration) *Request
- func (r *Request) TraceInfo() TraceInfo
- type RequestMiddleware
- type Response
- func Delete(url string) (*Response, error)
- func Get(url string) (*Response, error)
- func Head(url string) (*Response, error)
- func MustDelete(url string) *Response
- func MustGet(url string) *Response
- func MustHead(url string) *Response
- func MustOptions(url string) *Response
- func MustPatch(url string) *Response
- func MustPost(url string) *Response
- func MustPut(url string) *Response
- func Options(url string) (*Response, error)
- func Patch(url string) (*Response, error)
- func Post(url string) (*Response, error)
- func Put(url string) (*Response, error)
- func (r *Response) Bytes() []byte
- func (r *Response) Dump() string
- func (r *Response) Error() anydeprecated
- func (r *Response) ErrorResult() any
- func (r *Response) GetContentType() string
- func (r *Response) GetHeader(key string) string
- func (r *Response) GetHeaderValues(key string) []string
- func (r *Response) GetStatus() string
- func (r *Response) GetStatusCode() int
- func (r *Response) HeaderToString() string
- func (r *Response) Into(v any) error
- func (r *Response) IsError() booldeprecated
- func (r *Response) IsErrorState() bool
- func (r *Response) IsSuccess() booldeprecated
- func (r *Response) IsSuccessState() bool
- func (r *Response) ReceivedAt() time.Time
- func (r *Response) Result() anydeprecated
- func (r *Response) ResultState() ResultState
- func (r *Response) SetBody(body []byte)
- func (r *Response) SetBodyString(body string)
- func (r *Response) String() string
- func (r *Response) SuccessResult() any
- func (r *Response) ToBytes() (body []byte, err error)
- func (r *Response) ToString() (string, error)
- func (r *Response) TotalTime() time.Duration
- func (r *Response) TraceInfo() TraceInfo
- func (r *Response) Unmarshal(v any) error
- func (r *Response) UnmarshalJson(v any) error
- func (r *Response) UnmarshalXml(v any) error
- type ResponseMiddleware
- type ResultState
- type RetryConditionFunc
- type RetryHookFunc
- type RoundTripFunc
- type RoundTripWrapper
- type RoundTripWrapperFunc
- type RoundTripper
- type TraceInfo
- type Transport
- func (t *Transport) CancelRequest(req *http.Request)deprecated
- func (t *Transport) Clone() *Transport
- func (t *Transport) CloseIdleConnections()
- func (t *Transport) DisableAutoDecode() *Transport
- func (t *Transport) DisableDump()
- func (t *Transport) DisableForceHttpVersion() *Transport
- func (t *Transport) DisableH2C() *Transport
- func (t *Transport) DisableHTTP3()
- func (t *Transport) EnableAutoDecode() *Transport
- func (t *Transport) EnableDump(opt *DumpOptions)
- func (t *Transport) EnableForceHTTP1() *Transport
- func (t *Transport) EnableForceHTTP2() *Transport
- func (t *Transport) EnableForceHTTP3() *Transport
- func (t *Transport) EnableH2C() *Transport
- func (t *Transport) EnableHTTP3()
- func (t *Transport) GetMaxIdleConns() int
- func (t *Transport) RoundTrip(req *http.Request) (resp *http.Response, err error)
- func (t *Transport) SetAutoDecodeAllContentType() *Transport
- func (t *Transport) SetAutoDecodeContentType(contentTypes ...string)
- func (t *Transport) SetAutoDecodeContentTypeFunc(fn func(contentType string) bool) *Transport
- func (t *Transport) SetDebug(debugf func(format string, v ...any)) *Transport
- func (t *Transport) SetDial(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Transport
- func (t *Transport) SetDialTLS(fn func(ctx context.Context, network, addr string) (net.Conn, error)) *Transport
- func (t *Transport) SetExpectContinueTimeout(timeout time.Duration) *Transport
- func (t *Transport) SetGetProxyConnectHeader(...) *Transport
- func (t *Transport) SetHTTP2ConnectionFlow(flow uint32) *Transport
- func (t *Transport) SetHTTP2HeaderPriority(priority http2.PriorityParam) *Transport
- func (t *Transport) SetHTTP2MaxHeaderListSize(max uint32) *Transport
- func (t *Transport) SetHTTP2PingTimeout(timeout time.Duration) *Transport
- func (t *Transport) SetHTTP2PriorityFrames(frames ...http2.PriorityFrame) *Transport
- func (t *Transport) SetHTTP2ReadIdleTimeout(timeout time.Duration) *Transport
- func (t *Transport) SetHTTP2SettingsFrame(settings ...http2.Setting) *Transport
- func (t *Transport) SetHTTP2StrictMaxConcurrentStreams(strict bool) *Transport
- func (t *Transport) SetHTTP2WriteByteTimeout(timeout time.Duration) *Transport
- func (t *Transport) SetIdleConnTimeout(timeout time.Duration) *Transport
- func (t *Transport) SetMaxConnsPerHost(max int) *Transport
- func (t *Transport) SetMaxIdleConns(max int) *Transport
- func (t *Transport) SetMaxResponseHeaderBytes(max int64) *Transport
- func (t *Transport) SetProxy(proxy func(*http.Request) (*url.URL, error)) *Transport
- func (t *Transport) SetProxyConnectHeader(header http.Header) *Transport
- func (t *Transport) SetReadBufferSize(size int) *Transport
- func (t *Transport) SetResponseHeaderTimeout(timeout time.Duration) *Transport
- func (t *Transport) SetTLSClientConfig(cfg *tls.Config) *Transport
- func (t *Transport) SetTLSHandshake(...) *Transport
- func (t *Transport) SetTLSHandshakeTimeout(timeout time.Duration) *Transport
- func (t *Transport) SetWriteBufferSize(size int) *Transport
- func (t *Transport) WrapRoundTrip(wrappers ...HttpRoundTripWrapper) *Transport
- func (t *Transport) WrapRoundTripFunc(funcs ...HttpRoundTripWrapperFunc) *Transport
- type UploadCallback
- type UploadInfo
const (
HeaderOderKey = "__header_order__"
PseudoHeaderOderKey = "__pseudo_header_order__")
NoBody is an io.ReadCloser with no bytes. Read always returns EOF and Close always returns nil. It can be used in an outgoing client request to explicitly signal that a request has zero bytes. An alternative, however, is to simply set Request.Body to nil.
GetClient is a global wrapper methods which delegated to the default client's Client.GetClient.
GetCookies is a global wrapper methods which delegated to the default client's Client.GetCookies.
GetTLSClientConfig is a global wrapper methods which delegated to the default client's Client.GetTLSClientConfig.
func SetDefaultClient(c *Client)
SetDefaultClient override the global default Client.
Client is the req's http client.
func AddCommonQueryParam(key, value string) *Client
AddCommonQueryParam is a global wrapper methods which delegated to the default client's Client.AddCommonQueryParam.
AddCommonQueryParams is a global wrapper methods which delegated to the default client's Client.AddCommonQueryParams.
func AddCommonRetryCondition(condition RetryConditionFunc) *Client
AddCommonRetryCondition is a global wrapper methods which delegated to the default client's Client.AddCommonRetryCondition.
func AddCommonRetryHook(hook RetryHookFunc) *Client
AddCommonRetryHook is a global wrapper methods which delegated to the default client's Client.AddCommonRetryHook.
func ClearCookies() *Client
ClearCookies is a global wrapper methods which delegated to the default client's Client.ClearCookies.
func DefaultClient() *Client
DefaultClient returns the global default Client.
DevMode is a global wrapper methods which delegated to the default client's Client.DevMode.
func DisableAllowGetMethodPayload() *Client
DisableAllowGetMethodPayload is a global wrapper methods which delegated to the default client's Client.DisableAllowGetMethodPayload.
func DisableAutoDecode() *Client
DisableAutoDecode is a global wrapper methods which delegated to the default client's Client.DisableAutoDecode.
func DisableAutoReadResponse() *Client
DisableAutoReadResponse is a global wrapper methods which delegated to the default client's Client.DisableAutoReadResponse.
func DisableCompression() *Client
DisableCompression is a global wrapper methods which delegated to the default client's Client.DisableCompression.
func DisableDebugLog() *Client
DisableDebugLog is a global wrapper methods which delegated to the default client's Client.DisableDebugLog.
func DisableDumpAll() *Client
DisableDumpAll is a global wrapper methods which delegated to the default client's Client.DisableDumpAll.
func DisableForceHttpVersion() *Client
DisableForceHttpVersion is a global wrapper methods which delegated to the default client's Client.DisableForceHttpVersion.
func DisableH2C() *Client
DisableH2C is a global wrapper methods which delegated to the default client's Client.DisableH2C.
func DisableInsecureSkipVerify() *Client
DisableInsecureSkipVerify is a global wrapper methods which delegated to the default client's Client.DisableInsecureSkipVerify.
func DisableKeepAlives() *Client
DisableKeepAlives is a global wrapper methods which delegated to the default client's Client.DisableKeepAlives.
func DisableTraceAll() *Client
DisableTraceAll is a global wrapper methods which delegated to the default client's Client.DisableTraceAll.
func EnableAllowGetMethodPayload() *Client
EnableAllowGetMethodPayload is a global wrapper methods which delegated to the default client's Client.EnableAllowGetMethodPayload.
func EnableAutoDecode() *Client
EnableAutoDecode is a global wrapper methods which delegated to the default client's Client.EnableAutoDecode.
func EnableAutoReadResponse() *Client
EnableAutoReadResponse is a global wrapper methods which delegated to the default client's Client.EnableAutoReadResponse.
func EnableCompression() *Client
EnableCompression is a global wrapper methods which delegated to the default client's Client.EnableCompression.
func EnableDebugLog() *Client
EnableDebugLog is a global wrapper methods which delegated to the default client's Client.EnableDebugLog.
func EnableDumpAll() *Client
EnableDumpAll is a global wrapper methods which delegated to the default client's Client.EnableDumpAll.
func EnableDumpAllAsync() *Client
EnableDumpAllAsync is a global wrapper methods which delegated to the default client's Client.EnableDumpAllAsync.
EnableDumpAllTo is a global wrapper methods which delegated to the default client's Client.EnableDumpAllTo.
func EnableDumpAllToFile(filename string) *Client
EnableDumpAllToFile is a global wrapper methods which delegated to the default client's Client.EnableDumpAllToFile.
func EnableDumpAllWithoutBody ¶
func EnableDumpAllWithoutBody() *Client
EnableDumpAllWithoutBody is a global wrapper methods which delegated to the default client's Client.EnableDumpAllWithoutBody.
func EnableDumpAllWithoutHeader() *Client
EnableDumpAllWithoutHeader is a global wrapper methods which delegated to the default client's Client.EnableDumpAllWithoutHeader.
func EnableDumpAllWithoutRequest() *Client
EnableDumpAllWithoutRequest is a global wrapper methods which delegated to the default client's Client.EnableDumpAllWithoutRequest.
func EnableDumpAllWithoutRequestBody ¶
func EnableDumpAllWithoutRequestBody() *Client
EnableDumpAllWithoutRequestBody is a global wrapper methods which delegated to the default client's Client.EnableDumpAllWithoutRequestBody.
func EnableDumpAllWithoutResponse() *Client
EnableDumpAllWithoutResponse is a global wrapper methods which delegated to the default client's Client.EnableDumpAllWithoutResponse.
func EnableDumpAllWithoutResponseBody ¶
func EnableDumpAllWithoutResponseBody() *Client
EnableDumpAllWithoutResponseBody is a global wrapper methods which delegated to the default client's Client.EnableDumpAllWithoutResponseBody.
func EnableDumpEachRequest() *Client
EnableDumpEachRequest is a global wrapper methods which delegated to the default client's Client.EnableDumpEachRequest.
func EnableDumpEachRequestWithoutBody ¶ added in v3.18.0
func EnableDumpEachRequestWithoutBody() *Client
EnableDumpEachRequestWithoutBody is a global wrapper methods which delegated to the default client's Client.EnableDumpEachRequestWithoutBody.
func EnableDumpEachRequestWithoutHeader() *Client
EnableDumpEachRequestWithoutHeader is a global wrapper methods which delegated to the default client's Client.EnableDumpEachRequestWithoutHeader.
func EnableDumpEachRequestWithoutRequest() *Client
EnableDumpEachRequestWithoutRequest is a global wrapper methods which delegated to the default client's Client.EnableDumpEachRequestWithoutRequest.
func EnableDumpEachRequestWithoutRequestBody ¶ added in v3.18.0
func EnableDumpEachRequestWithoutRequestBody() *Client
EnableDumpEachRequestWithoutRequestBody is a global wrapper methods which delegated to the default client's Client.EnableDumpEachRequestWithoutRequestBody.
func EnableDumpEachRequestWithoutResponse() *Client
EnableDumpEachRequestWithoutResponse is a global wrapper methods which delegated to the default client's Client.EnableDumpEachRequestWithoutResponse.
func EnableDumpEachRequestWithoutResponseBody ¶ added in v3.18.0
func EnableDumpEachRequestWithoutResponseBody() *Client
EnableDumpEachRequestWithoutResponseBody is a global wrapper methods which delegated to the default client's Client.EnableDumpEachRequestWithoutResponseBody.
func EnableForceHTTP1() *Client
EnableForceHTTP1 is a global wrapper methods which delegated to the default client's Client.EnableForceHTTP1.
func EnableForceHTTP2() *Client
EnableForceHTTP2 is a global wrapper methods which delegated to the default client's Client.EnableForceHTTP2.
func EnableForceHTTP3() *Client
EnableForceHTTP3 is a global wrapper methods which delegated to the default client's Client.EnableForceHTTP3.
EnableH2C is a global wrapper methods which delegated to the default client's Client.EnableH2C.
func EnableHTTP3() *Client
EnableHTTP3 is a global wrapper methods which delegated to the default client's Client.EnableHTTP3.
func EnableInsecureSkipVerify() *Client
EnableInsecureSkipVerify is a global wrapper methods which delegated to the default client's Client.EnableInsecureSkipVerify.
func EnableKeepAlives() *Client
EnableKeepAlives is a global wrapper methods which delegated to the default client's Client.EnableKeepAlives.
func EnableTraceAll() *Client
EnableTraceAll is a global wrapper methods which delegated to the default client's Client.EnableTraceAll.
func ImpersonateChrome() *Client
ImpersonateChrome is a global wrapper methods which delegated to the default client's Client.ImpersonateChrome.
func ImpersonateFirefox() *Client
ImpersonateChrome is a global wrapper methods which delegated to the default client's Client.ImpersonateChrome.
func ImpersonateSafari() *Client
ImpersonateChrome is a global wrapper methods which delegated to the default client's Client.ImpersonateChrome.
NewClient is the alias of C
func OnAfterResponse(m ResponseMiddleware) *Client
OnAfterResponse is a global wrapper methods which delegated to the default client's Client.OnAfterResponse.
func OnBeforeRequest(m RequestMiddleware) *Client
OnBeforeRequest is a global wrapper methods which delegated to the default client's Client.OnBeforeRequest.
func SetAutoDecodeAllContentType ¶ added in v3.3.0
func SetAutoDecodeAllContentType() *Client
SetAutoDecodeAllContentType is a global wrapper methods which delegated to the default client's Client.SetAutoDecodeAllContentType.
func SetAutoDecodeContentType ¶
func SetAutoDecodeContentType(contentTypes ...string) *Client
SetAutoDecodeContentType is a global wrapper methods which delegated to the default client's Client.SetAutoDecodeContentType.
func SetAutoDecodeContentTypeFunc ¶ added in v3.3.0
func SetAutoDecodeContentTypeFunc(fn func(contentType string) bool) *Client
SetAutoDecodeContentTypeFunc is a global wrapper methods which delegated to the default client's Client.SetAutoDecodeAllTypeFunc.
SetBaseURL is a global wrapper methods which delegated to the default client's Client.SetBaseURL.
func SetCertFromFile(certFile, keyFile string) *Client
SetCertFromFile is a global wrapper methods which delegated to the default client's Client.SetCertFromFile.
SetCerts is a global wrapper methods which delegated to the default client's Client.SetCerts.
func SetCommonBasicAuth(username, password string) *Client
SetCommonBasicAuth is a global wrapper methods which delegated to the default client's Client.SetCommonBasicAuth.
func SetCommonBearerAuthToken(token string) *Client
SetCommonBearerAuthToken is a global wrapper methods which delegated to the default client's Client.SetCommonBearerAuthToken.
func SetCommonContentType ¶
func SetCommonContentType(ct string) *Client
SetCommonContentType is a global wrapper methods which delegated to the default client's Client.SetCommonContentType.
SetCommonCookies is a global wrapper methods which delegated to the default client's Client.SetCommonCookies.
func SetCommonDigestAuth(username, password string) *Client
SetCommonDigestAuth is a global wrapper methods which delegated to the default client's Client.SetCommonDigestAuth.
func SetCommonDumpOptions(opt *DumpOptions) *Client
SetCommonDumpOptions is a global wrapper methods which delegated to the default client's Client.SetCommonDumpOptions.
func SetCommonError(err any) *Client
SetCommonError is a global wrapper methods which delegated to the default client's Client.SetCommonErrorResult.
Deprecated: Use SetCommonErrorResult instead.
func SetCommonErrorResult(err any) *Client
SetCommonErrorResult is a global wrapper methods which delegated to the default client's Client.SetCommonError.
SetCommonFormData is a global wrapper methods which delegated to the default client's Client.SetCommonFormData.
func SetCommonFormDataFromValues(data url.Values) *Client
SetCommonFormDataFromValues is a global wrapper methods which delegated to the default client's Client.SetCommonFormDataFromValues.
func SetCommonHeader(key, value string) *Client
SetCommonHeader is a global wrapper methods which delegated to the default client's Client.SetCommonHeader.
func SetCommonHeaderOrder(keys ...string) *Client
SetCommonHeaderOrder is a global wrapper methods which delegated to the default client's Client.SetCommonHeaderOrder.
SetCommonHeaders is a global wrapper methods which delegated to the default client's Client.SetCommonHeaders.
func SetCommonPathParam(key, value string) *Client
SetCommonPathParam is a global wrapper methods which delegated to the default client's Client.SetCommonPathParam.
SetCommonPathParams is a global wrapper methods which delegated to the default client's Client.SetCommonPathParams.
func SetCommonPseudoHeaderOder(keys ...string) *Client
SetCommonPseudoHeaderOder is a global wrapper methods which delegated to the default client's Client.SetCommonPseudoHeaderOder.
func SetCommonQueryParam(key, value string) *Client
SetCommonQueryParam is a global wrapper methods which delegated to the default client's Client.SetCommonQueryParam.
SetCommonQueryParams is a global wrapper methods which delegated to the default client's Client.SetCommonQueryParams.
func SetCommonQueryParamsFromStruct(v any) *Client
SetCommonQueryParamsFromStruct is a global wrapper methods which delegated to the default client's Client.SetCommonQueryParamsFromStruct.
func SetCommonQueryParamsFromValues(params url.Values) *Client
SetCommonQueryParamsFromValues is a global wrapper methods which delegated to the default client's Client.SetCommonQueryParamsFromValues.
func SetCommonQueryString(query string) *Client
SetCommonQueryString is a global wrapper methods which delegated to the default client's Client.SetCommonQueryString.
SetCommonRetryBackoffInterval is a global wrapper methods which delegated to the default client's Client.SetCommonRetryBackoffInterval.
func SetCommonRetryCondition(condition RetryConditionFunc) *Client
SetCommonRetryCondition is a global wrapper methods which delegated to the default client's Client.SetCommonRetryCondition.
func SetCommonRetryCount(count int) *Client
SetCommonRetryCount is a global wrapper methods which delegated to the default client's Client.SetCommonRetryCount.
SetCommonRetryFixedInterval is a global wrapper methods which delegated to the default client's Client.SetCommonRetryFixedInterval.
func SetCommonRetryHook(hook RetryHookFunc) *Client
SetCommonRetryHook is a global wrapper methods which delegated to the default client's Client.SetCommonRetryHook.
func SetCommonRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Client
SetCommonRetryInterval is a global wrapper methods which delegated to the default client's Client.SetCommonRetryInterval.
SetCookieJar is a global wrapper methods which delegated to the default client's Client.SetCookieJar.
SetDial is a global wrapper methods which delegated to the default client's Client.SetDial.
SetDialTLS is a global wrapper methods which delegated to the default client's Client.SetDialTLS.
func SetHTTP2ConnectionFlow(flow uint32) *Client
SetHTTP2ConnectionFlow is a global wrapper methods which delegated to the default client's Client.SetHTTP2ConnectionFlow.
SetHTTP2HeaderPriority is a global wrapper methods which delegated to the default client's Client.SetHTTP2HeaderPriority.
func SetHTTP2MaxHeaderListSize(max uint32) *Client
SetHTTP2MaxHeaderListSize is a global wrapper methods which delegated to the default client's Client.SetHTTP2MaxHeaderListSize.
SetHTTP2PingTimeout is a global wrapper methods which delegated to the default client's Client.SetHTTP2PingTimeout.
SetHTTP2PriorityFrames is a global wrapper methods which delegated to the default client's Client.SetHTTP2PriorityFrames.
SetHTTP2ReadIdleTimeout is a global wrapper methods which delegated to the default client's Client.SetHTTP2ReadIdleTimeout.
SetHTTP2SettingsFrame is a global wrapper methods which delegated to the default client's Client.SetHTTP2SettingsFrame.
func SetHTTP2StrictMaxConcurrentStreams(strict bool) *Client
SetHTTP2StrictMaxConcurrentStreams is a global wrapper methods which delegated to the default client's Client.SetHTTP2StrictMaxConcurrentStreams.
SetHTTP2WriteByteTimeout is a global wrapper methods which delegated to the default client's Client.SetHTTP2WriteByteTimeout.
SetJsonMarshal is a global wrapper methods which delegated to the default client's Client.SetJsonMarshal.
SetJsonUnmarshal is a global wrapper methods which delegated to the default client's Client.SetJsonUnmarshal.
func SetLogger(log Logger) *Client
SetLogger is a global wrapper methods which delegated to the default client's Client.SetLogger.
func SetMultipartBoundaryFunc(fn func() string) *Client
SetMultipartBoundaryFunc is a global wrapper methods which delegated to the default client's Client.SetMultipartBoundaryFunc.
func SetOutputDirectory(dir string) *Client
SetOutputDirectory is a global wrapper methods which delegated to the default client's Client.SetOutputDirectory.
SetProxy is a global wrapper methods which delegated to the default client's Client.SetProxy.
func SetProxyURL(proxyUrl string) *Client
SetProxyURL is a global wrapper methods which delegated to the default client's Client.SetProxyURL.
func SetRedirectPolicy(policies ...RedirectPolicy) *Client
SetRedirectPolicy is a global wrapper methods which delegated to the default client's Client.SetRedirectPolicy.
func SetResponseBodyTransformer ¶ added in v3.28.0
func SetResponseBodyTransformer(fn func(rawBody []byte, req *Request, resp *Response) (transformedBody []byte, err error)) *Client
SetResponseBodyTransformer is a global wrapper methods which delegated to the default client's Client.SetResponseBodyTransformer.
func SetResultStateCheckFunc(fn func(resp *Response) ResultState) *Client
SetResultStateCheckFunc is a global wrapper methods which delegated to the default client's Client.SetCommonResultStateCheckFunc.
func SetRootCertFromString(pemContent string) *Client
SetRootCertFromString is a global wrapper methods which delegated to the default client's Client.SetRootCertFromString.
func SetRootCertsFromFile(pemFiles ...string) *Client
SetRootCertsFromFile is a global wrapper methods which delegated to the default client's Client.SetRootCertsFromFile.
SetScheme is a global wrapper methods which delegated to the default client's Client.SetScheme.
SetTLSClientConfig is a global wrapper methods which delegated to the default client's Client.SetTLSClientConfig.
SetTLSFingerprint is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprint.
func SetTLSFingerprint360() *Client
SetTLSFingerprint360 is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprint360.
func SetTLSFingerprintAndroid ¶ added in v3.37.0
func SetTLSFingerprintAndroid() *Client
SetTLSFingerprintAndroid is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintAndroid.
func SetTLSFingerprintChrome() *Client
SetTLSFingerprintChrome is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintChrome.
func SetTLSFingerprintEdge() *Client
SetTLSFingerprintEdge is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintEdge.
func SetTLSFingerprintFirefox() *Client
SetTLSFingerprintFirefox is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintFirefox.
func SetTLSFingerprintIOS() *Client
SetTLSFingerprintIOS is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintIOS.
func SetTLSFingerprintQQ() *Client
SetTLSFingerprintQQ is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintQQ.
func SetTLSFingerprintRandomized ¶ added in v3.37.0
func SetTLSFingerprintRandomized() *Client
SetTLSFingerprintRandomized is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintRandomized.
func SetTLSFingerprintSafari() *Client
SetTLSFingerprintSafari is a global wrapper methods which delegated to the default client's Client.SetTLSFingerprintSafari.
func SetTLSHandshakeTimeout ¶ added in v3.2.0
SetTLSHandshakeTimeout is a global wrapper methods which delegated to the default client's Client.SetTLSHandshakeTimeout.
SetTimeout is a global wrapper methods which delegated to the default client's Client.SetTimeout.
func SetUnixSocket(file string) *Client
SetUnixSocket is a global wrapper methods which delegated to the default client's Client.SetUnixSocket.
func SetUserAgent(userAgent string) *Client
SetUserAgent is a global wrapper methods which delegated to the default client's Client.SetUserAgent.
SetXmlMarshal is a global wrapper methods which delegated to the default client's Client.SetXmlMarshal.
SetXmlUnmarshal is a global wrapper methods which delegated to the default client's Client.SetXmlUnmarshal.
func WrapRoundTrip(wrappers ...RoundTripWrapper) *Client
WrapRoundTrip is a global wrapper methods which delegated to the default client's Client.WrapRoundTrip.
func WrapRoundTripFunc(funcs ...RoundTripWrapperFunc) *Client
WrapRoundTripFunc is a global wrapper methods which delegated to the default client's Client.WrapRoundTripFunc.
func (c *Client) AddCommonQueryParam(key, value string) *Client
AddCommonQueryParam add a URL query parameter with a key-value pair for requests fired from the client.
AddCommonQueryParams add one or more values of specified URL query parameter for requests fired from the client.
func (c *Client) AddCommonRetryCondition(condition RetryConditionFunc) *Client
AddCommonRetryCondition adds a retry condition, which determines whether the request should retry.
func (c *Client) AddCommonRetryHook(hook RetryHookFunc) *Client
AddCommonRetryHook adds a retry hook for requests fired from the client, which will be executed before a retry.
func (c *Client) ClearCookies() *Client
ClearCookies clears all cookies if cookie is enabled, including cookies from cookie jar and cookies set by SetCommonCookies. Note: The cookie jar will not be cleared if you called SetCookieJar instead of SetCookieJarFactory.
func (c *Client) Clone() *Client
Clone copy and returns the Client
Delete create a new DELETE request.
func (c *Client) DevMode() *Client
DevMode enables: 1. Dump content of all requests and responses to see details. 2. Output debug level log for deeper insights. 3. Trace all requests, so you can get trace info to analyze performance.
func (c *Client) DisableAllowGetMethodPayload() *Client
DisableAllowGetMethodPayload disable sending GET method requests with body.
func (c *Client) DisableAutoDecode() *Client
DisableAutoDecode disable auto-detect charset and decode to utf-8 (enabled by default).
func (c *Client) DisableAutoDecompress() *Client
DisableAutoDecompress disables the automatic decompression (disabled by default).
func (c *Client) DisableAutoReadResponse() *Client
DisableAutoReadResponse disable read response body automatically (enabled by default).
func (c *Client) DisableCompression() *Client
DisableCompression disables the compression (enabled by default), which prevents the Transport from requesting compression with an "Accept-Encoding: gzip" request header when the Request contains no existing Accept-Encoding value. If the Transport requests gzip on its own and gets a gzipped response, it's transparently decoded in the Response.Body. However, if the user explicitly requested gzip it is not automatically uncompressed.
func (c *Client) DisableDebugLog() *Client
DisableDebugLog disable debug level log (disabled by default).
func (c *Client) DisableDumpAll() *Client
DisableDumpAll disable dump for requests fired from the client.
func (c *Client) DisableForceHttpVersion() *Client
DisableForceHttpVersion disable force using specified http version (disabled by default).
func (c *Client) DisableH2C() *Client
DisableH2C disables HTTP/2 over TCP without TLS.
func (c *Client) DisableHTTP3() *Client
DisableHTTP3 disables the http3 protocol.
func (c *Client) DisableInsecureSkipVerify() *Client
DisableInsecureSkipVerify disable send https without verifying the server's certificates (disabled by default).
func (c *Client) DisableKeepAlives() *Client
DisableKeepAlives disable the HTTP keep-alives (enabled by default) and will only use the connection to the server for a single HTTP request.
This is unrelated to the similarly named TCP keep-alives.
func (c *Client) DisableTraceAll() *Client
DisableTraceAll disable trace for requests fired from the client.
Do is compatible with http.Client.Do, which can make req integration easier in some scenarios. It should be noted that this will make some req features not work properly, such as automatic retry, client middleware, etc.
func (c *Client) EnableAllowGetMethodPayload() *Client
EnableAllowGetMethodPayload allows sending GET method requests with body.
func (c *Client) EnableAutoDecode() *Client
EnableAutoDecode enable auto-detect charset and decode to utf-8 (enabled by default).
func (c *Client) EnableAutoDecompress() *Client
EnableAutoDecompress enables the automatic decompression (disabled by default).
func (c *Client) EnableAutoReadResponse() *Client
EnableAutoReadResponse enable read response body automatically (enabled by default).
func (c *Client) EnableCompression() *Client
EnableCompression enables the compression (enabled by default).
func (c *Client) EnableDebugLog() *Client
EnableDebugLog enable debug level log (disabled by default).
func (c *Client) EnableDumpAll() *Client
EnableDumpAll enable dump for requests fired from the client, including all content for the request and response by default.
func (c *Client) EnableDumpAllAsync() *Client
EnableDumpAllAsync enable dump for requests fired from the client and output asynchronously, can be used for debugging in production environment without affecting performance.
func (c *Client) EnableDumpAllTo(output io.Writer) *Client
EnableDumpAllTo enable dump for requests fired from the client and output to the specified io.Writer.
func (c *Client) EnableDumpAllToFile(filename string) *Client
EnableDumpAllToFile enable dump for requests fired from the client and output to the specified file.
func (*Client) EnableDumpAllWithoutBody ¶
func (c *Client) EnableDumpAllWithoutBody() *Client
EnableDumpAllWithoutBody enable dump for requests fired from the client without body, can be used if you only care about the header.
func (c *Client) EnableDumpAllWithoutHeader() *Client
EnableDumpAllWithoutHeader enable dump for requests fired from the client without header, can be used if you only care about the body.
func (c *Client) EnableDumpAllWithoutRequest() *Client
EnableDumpAllWithoutRequest enables dump for requests fired from the client without request, can be used if you only care about the response.
func (*Client) EnableDumpAllWithoutRequestBody ¶
func (c *Client) EnableDumpAllWithoutRequestBody() *Client
EnableDumpAllWithoutRequestBody enable dump for requests fired from the client without request body, can be used in the upload request to avoid dumping the unreadable binary content.
func (c *Client) EnableDumpAllWithoutResponse() *Client
EnableDumpAllWithoutResponse enable dump for requests fired from the client without response, can be used if you only care about the request.
func (*Client) EnableDumpAllWithoutResponseBody ¶
func (c *Client) EnableDumpAllWithoutResponseBody() *Client
EnableDumpAllWithoutResponseBody enable dump for requests fired from the client without response body, can be used in the download request to avoid dumping the unreadable binary content.
func (c *Client) EnableDumpEachRequest() *Client
EnableDumpEachRequest enable dump at the request-level for each request, and only temporarily stores the dump content in memory, call Response.Dump() to get the dump content when needed.
func (*Client) EnableDumpEachRequestWithoutBody ¶ added in v3.18.0
func (c *Client) EnableDumpEachRequestWithoutBody() *Client
EnableDumpEachRequestWithoutBody enable dump without body at the request-level for each request, and only temporarily stores the dump content in memory, call Response.Dump() to get the dump content when needed.
func (c *Client) EnableDumpEachRequestWithoutHeader() *Client
EnableDumpEachRequestWithoutHeader enable dump without header at the request-level for each request, and only temporarily stores the dump content in memory, call Response.Dump() to get the dump content when needed.
func (c *Client) EnableDumpEachRequestWithoutRequest() *Client
EnableDumpEachRequestWithoutRequest enable dump without request at the request-level for each request, and only temporarily stores the dump content in memory, call Response.Dump() to get the dump content when needed.
func (*Client) EnableDumpEachRequestWithoutRequestBody ¶ added in v3.18.0
func (c *Client) EnableDumpEachRequestWithoutRequestBody() *Client
EnableDumpEachRequestWithoutRequestBody enable dump without request body at the request-level for each request, and only temporarily stores the dump content in memory, call Response.Dump() to get the dump content when needed.
func (c *Client) EnableDumpEachRequestWithoutResponse() *Client
EnableDumpEachRequestWithoutResponse enable dump without response at the request-level for each request, and only temporarily stores the dump content in memory, call Response.Dump() to get the dump content when needed.
func (*Client) EnableDumpEachRequestWithoutResponseBody ¶ added in v3.18.0
func (c *Client) EnableDumpEachRequestWithoutResponseBody() *Client
EnableDumpEachRequestWithoutResponseBody enable dump without response body at the request-level for each request, and only temporarily stores the dump content in memory, call Response.Dump() to get the dump content when needed.
func (c *Client) EnableForceHTTP1() *Client
EnableForceHTTP1 enable force using HTTP1 (disabled by default).
Attention: This method should not be called when ImpersonateXXX, SetTLSFingerPrint or SetTLSHandshake and other methods that will customize the tls handshake are called.
func (c *Client) EnableForceHTTP2() *Client
EnableForceHTTP2 enable force using HTTP2 for https requests (disabled by default).
Attention: This method should not be called when ImpersonateXXX, SetTLSFingerPrint or SetTLSHandshake and other methods that will customize the tls handshake are called.
func (c *Client) EnableForceHTTP3() *Client
EnableForceHTTP3 enable force using HTTP3 for https requests (disabled by default).
Attention: This method should not be called when ImpersonateXXX, SetTLSFingerPrint or SetTLSHandshake and other methods that will customize the tls handshake are called.
func (c *Client) EnableH2C() *Client
EnableH2C enables HTTP/2 over TCP without TLS.
func (c *Client) EnableHTTP3() *Client
EnableHTTP3 enables the http3 protocol.
func (c *Client) EnableInsecureSkipVerify() *Client
EnableInsecureSkipVerify enable send https without verifying the server's certificates (disabled by default).
func (c *Client) EnableKeepAlives() *Client
EnableKeepAlives enables HTTP keep-alives (enabled by default).
func (c *Client) EnableTraceAll() *Client
EnableTraceAll enable trace for requests fired from the client (http3 currently does not support trace).
Get create a new GET request, accepts 0 or 1 url.
GetClient returns the underlying `http.Client`.
GetCookies get cookies from the underlying `http.Client`'s `CookieJar`.
func (c *Client) GetLogger() Logger
GetLogger return the internal logger, usually used in middleware.
GetTLSClientConfig return the underlying tls.Config.
func (c *Client) GetTransport() *Transport
GetTransport return the underlying transport.
Head create a new HEAD request.
func (c *Client) ImpersonateChrome() *Client
ImpersonateChrome impersonates Chrome browser (version 120).
func (c *Client) ImpersonateFirefox() *Client
ImpersonateFirefox impersonates Firefox browser (version 120).
func (c *Client) ImpersonateSafari() *Client
ImpersonateSafari impersonates Safari browser (version 16.6).
func (c *Client) NewParallelDownload(url string) *ParallelDownload
func (c *Client) NewRequest() *Request
NewRequest is the alias of R()
func (c *Client) OnAfterResponse(m ResponseMiddleware) *Client
OnAfterResponse add a response middleware which hooks after response received.
func (c *Client) OnBeforeRequest(m RequestMiddleware) *Client
OnBeforeRequest add a request middleware which hooks before request sent.
func (c *Client) OnError(hook ErrorHook) *Client
OnError set the error hook which will be executed if any error returned, even if the occurs before request is sent (e.g. invalid URL).
Options create a new OPTIONS request.
Patch create a new PATCH request.
Post create a new POST request.
Put create a new PUT request.
R create a new request.
func (*Client) SetAutoDecodeAllContentType ¶ added in v3.3.0
func (c *Client) SetAutoDecodeAllContentType() *Client
SetAutoDecodeAllContentType enable try auto-detect charset and decode all content type to utf-8.
func (*Client) SetAutoDecodeContentType ¶
func (c *Client) SetAutoDecodeContentType(contentTypes ...string) *Client
SetAutoDecodeContentType set the content types that will be auto-detected and decode to utf-8 (e.g. "json", "xml", "html", "text").
func (*Client) SetAutoDecodeContentTypeFunc ¶ added in v3.3.0
func (c *Client) SetAutoDecodeContentTypeFunc(fn func(contentType string) bool) *Client
SetAutoDecodeContentTypeFunc set the function that determines whether the specified `Content-Type` should be auto-detected and decode to utf-8.
SetBaseURL set the default base URL, will be used if request URL is a relative URL.
func (c *Client) SetCertFromFile(certFile, keyFile string) *Client
SetCertFromFile helps to set client certificates from cert and key file.
SetCerts set client certificates.
func (c *Client) SetCommonBasicAuth(username, password string) *Client
SetCommonBasicAuth set the basic auth for requests fired from the client.
func (c *Client) SetCommonBearerAuthToken(token string) *Client
SetCommonBearerAuthToken set the bearer auth token for requests fired from the client.
func (*Client) SetCommonContentType ¶
func (c *Client) SetCommonContentType(ct string) *Client
SetCommonContentType set the `Content-Type` header for requests fired from the client.
SetCommonCookies set HTTP cookies for requests fired from the client.
func (c *Client) SetCommonDigestAuth(username, password string) *Client
SetCommonDigestAuth sets the Digest Access auth scheme for requests fired from the client. If a server responds with 401 and sends a Digest challenge in the WWW-Authenticate Header, requests will be resent with the appropriate Authorization Header.
For Example: To set the Digest scheme with user "roc" and password "123456"
client.SetCommonDigestAuth("roc", "123456")
Information about Digest Access Authentication can be found in RFC7616:
https://datatracker.ietf.org/doc/html/rfc7616
func (c *Client) SetCommonDumpOptions(opt *DumpOptions) *Client
SetCommonDumpOptions configures the underlying Transport's DumpOptions for requests fired from the client.
func (c *Client) SetCommonError(err any) *Client
SetCommonError set the common result that response body will be unmarshalled to if no error occurs but Response.ResultState returns ErrorState, by default it is HTTP status `code >= 400`, you can also use SetCommonResultStateChecker to customize the result state check logic.
Deprecated: Use SetCommonErrorResult instead.
func (c *Client) SetCommonErrorResult(err any) *Client
SetCommonErrorResult set the common result that response body will be unmarshalled to if no error occurs but Response.ResultState returns ErrorState, by default it is HTTP status `code >= 400`, you can also use SetCommonResultStateChecker to customize the result state check logic.
SetCommonFormData set the form data from map for requests fired from the client which request method allows payload.
SetCommonFormDataFromValues set the form data from url.Values for requests fired from the client which request method allows payload.
func (c *Client) SetCommonHeader(key, value string) *Client
SetCommonHeader set a header for requests fired from the client.
func (c *Client) SetCommonHeaderNonCanonical(key, value string) *Client
SetCommonHeaderNonCanonical set a header for requests fired from the client which key is a non-canonical key (keep case unchanged), only valid for HTTP/1.1.
func (c *Client) SetCommonHeaderOrder(keys ...string) *Client
SetCommonHeaderOrder set the order of the http header requests fired from the client (case-insensitive). For example:
client.R().SetCommonHeaderOrder( "custom-header", "cookie", "user-agent", "accept-encoding", ).Get(url
SetCommonHeaders set headers for requests fired from the client.
SetCommonHeadersNonCanonical set headers for requests fired from the client which key is a non-canonical key (keep case unchanged), only valid for HTTP/1.1.
func (c *Client) SetCommonPathParam(key, value string) *Client
SetCommonPathParam set a path parameter for requests fired from the client.
SetCommonPathParams set path parameters for requests fired from the client.
func (c *Client) SetCommonPseudoHeaderOder(keys ...string) *Client
SetCommonPseudoHeaderOder set the order of the pseudo http header requests fired from the client (case-insensitive). Note this is only valid for http2 and http3. For example:
client.SetCommonPseudoHeaderOder( ":scheme", ":authority", ":path", ":method", )
func (c *Client) SetCommonQueryParam(key, value string) *Client
SetCommonQueryParam set a URL query parameter with a key-value pair for requests fired from the client.
SetCommonQueryParams set URL query parameters with a map for requests fired from the client.
func (c *Client) SetCommonQueryParamsFromStruct(v any) *Client
SetCommonQueryParamsFromStruct set URL query parameters from a struct using go-querystring for requests fired from the client.
SetCommonQueryParamsFromValues set URL query parameters from a url.Values map for requests fired from the client.
func (c *Client) SetCommonQueryString(query string) *Client
SetCommonQueryString set URL query parameters with a raw query string for requests fired from the client.
func (c *Client) SetCommonRetryCondition(condition RetryConditionFunc) *Client
SetCommonRetryCondition sets the retry condition, which determines whether the request should retry. It will override other retry conditions if any been added before.
func (c *Client) SetCommonRetryCount(count int) *Client
SetCommonRetryCount enables retry and set the maximum retry count for requests fired from the client. It will retry infinitely if count is negative.
SetCommonRetryFixedInterval set retry to use a fixed interval for requests fired from the client.
func (c *Client) SetCommonRetryHook(hook RetryHookFunc) *Client
SetCommonRetryHook set the retry hook which will be executed before a retry. It will override other retry hooks if any been added before.
func (c *Client) SetCommonRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Client
SetCommonRetryInterval sets the custom GetRetryIntervalFunc for requests fired from the client, you can use this to implement your own backoff retry algorithm. For example:
req.SetCommonRetryInterval(func(resp *req.Response, attempt int) time.Duration {
sleep := 0.01 * math.Exp2(float64(attempt))
return time.Duration(math.Min(2, sleep)) * time.Second
})SetCookieJar set the cookie jar to the underlying `http.Client`, set to nil if you want to disable cookies. Note: If you use Client.Clone to clone a new Client, the new client will share the same cookie jar as the old Client after cloning. Use SetCookieJarFactory instead if you want to create a new CookieJar automatically when cloning a client.
SetCookieJarFactory set the functional factory of cookie jar, which creates cookie jar that store cookies for underlying `http.Client`. After client clone, the cookie jar of the new client will also be regenerated using this factory function.
SetDial set the customized `DialContext` function to Transport.
SetDialTLS set the customized `DialTLSContext` function to Transport. Make sure the returned `conn` implements pkg/tls.Conn if you want your customized `conn` supports HTTP2.
func (c *Client) SetHTTP2ConnectionFlow(flow uint32) *Client
SetHTTP2ConnectionFlow set the default http2 connection flow, which is the increment value of initial WINDOW_UPDATE frame.
SetHTTP2HeaderPriority set the header priority param.
func (c *Client) SetHTTP2MaxHeaderListSize(max uint32) *Client
SetHTTP2MaxHeaderListSize set the http2 MaxHeaderListSize, which is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to send in the initial settings frame. It is how many bytes of response headers are allowed. Unlike the http2 spec, zero here means to use a default limit (currently 10MB). If you actually want to advertise an unlimited value to the peer, Transport interprets the highest possible value here (0xffffffff or 1<<32-1) to mean no limit.
SetHTTP2PingTimeout set the http2 PingTimeout, which is the timeout after which the connection will be closed if a response to Ping is not received. Defaults to 15s
SetHTTP2PriorityFrames set the ordered http2 priority frames.
SetHTTP2ReadIdleTimeout set the http2 ReadIdleTimeout, which is the timeout after which a health check using ping frame will be carried out if no frame is received on the connection. Note that a ping response will is considered a received frame, so if there is no other traffic on the connection, the health check will be performed every ReadIdleTimeout interval. If zero, no health check is performed.
SetHTTP2SettingsFrame set the ordered http2 settings frame.
func (c *Client) SetHTTP2StrictMaxConcurrentStreams(strict bool) *Client
SetHTTP2StrictMaxConcurrentStreams set the http2 StrictMaxConcurrentStreams, which controls whether the server's SETTINGS_MAX_CONCURRENT_STREAMS should be respected globally. If false, new TCP connections are created to the server as needed to keep each under the per-connection SETTINGS_MAX_CONCURRENT_STREAMS limit. If true, the server's SETTINGS_MAX_CONCURRENT_STREAMS is interpreted as a global limit and callers of RoundTrip block when needed, waiting for their turn.
SetHTTP2WriteByteTimeout set the http2 WriteByteTimeout, which is the timeout after which the connection will be closed no data can be written to it. The timeout begins when data is available to write, and is extended whenever any bytes are written.
SetJsonMarshal set the JSON marshal function which will be used to marshal request body.
SetJsonUnmarshal set the JSON unmarshal function which will be used to unmarshal response body.
func (c *Client) SetLogger(log Logger) *Client
SetLogger set the customized logger for client, will disable log if set to nil.
func (c *Client) SetMultipartBoundaryFunc(fn func() string) *Client
SetMultipartBoundaryFunc overrides the default function used to generate boundary delimiters for "multipart/form-data" requests with a customized one, which returns a boundary delimiter (without the two leading hyphens).
Boundary delimiter may only contain certain ASCII characters, and must be non-empty and at most 70 bytes long (see RFC 2046, Section 5.1.1).
func (c *Client) SetOutputDirectory(dir string) *Client
SetOutputDirectory set output directory that response will be downloaded to.
SetProxy set the proxy function.
func (c *Client) SetProxyURL(proxyUrl string) *Client
SetProxyURL set proxy from the proxy URL.
func (c *Client) SetRedirectPolicy(policies ...RedirectPolicy) *Client
SetRedirectPolicy set the RedirectPolicy which controls the behavior of receiving redirect responses (usually responses with 301 and 302 status code), see the predefined AllowedDomainRedirectPolicy, AllowedHostRedirectPolicy, DefaultRedirectPolicy, MaxRedirectPolicy, NoRedirectPolicy, SameDomainRedirectPolicy and SameHostRedirectPolicy.
func (*Client) SetResponseBodyTransformer ¶ added in v3.28.0
func (c *Client) SetResponseBodyTransformer(fn func(rawBody []byte, req *Request, resp *Response) (transformedBody []byte, err error)) *Client
SetResponseBodyTransformer set the response body transformer, which can modify the response body before unmarshalled if auto-read response body is not disabled.
func (c *Client) SetResultStateCheckFunc(fn func(resp *Response) ResultState) *Client
SetResultStateCheckFunc overrides the default result state checker with customized one, which returns SuccessState when HTTP status `code >= 200 and <= 299`, and returns ErrorState when HTTP status `code >= 400`, otherwise returns UnknownState.
func (c *Client) SetRootCertFromString(pemContent string) *Client
SetRootCertFromString set root certificates from string.
func (c *Client) SetRootCertsFromFile(pemFiles ...string) *Client
SetRootCertsFromFile set root certificates from files.
func (c *Client) SetScheme(scheme string) *Client
SetScheme set the default scheme for client, will be used when there is no scheme in the request URL (e.g. "github.com/imroc/req").
SetTLSClientConfig set the TLS client config. Be careful! Usually you don't need this, you can directly set the tls configuration with methods like EnableInsecureSkipVerify, SetCerts etc. Or you can call GetTLSClientConfig to get the current tls configuration to avoid overwriting some important configurations, such as not setting NextProtos will not use http2 by default.
SetTLSFingerprint set the tls fingerprint for tls handshake, will use utls (https://github.com/refraction-networking/utls) to perform the tls handshake, which uses the specified clientHelloID to simulate the tls fingerprint. Note this is valid for HTTP1 and HTTP2, not HTTP3.
func (c *Client) SetTLSFingerprint360() *Client
SetTLSFingerprint360 uses tls fingerprint of 360 browser.
func (*Client) SetTLSFingerprintAndroid ¶ added in v3.36.0
func (c *Client) SetTLSFingerprintAndroid() *Client
SetTLSFingerprintAndroid uses tls fingerprint of Android.
func (c *Client) SetTLSFingerprintChrome() *Client
SetTLSFingerprintChrome uses tls fingerprint of Chrome browser.
func (c *Client) SetTLSFingerprintEdge() *Client
SetTLSFingerprintEdge uses tls fingerprint of Edge browser.
func (c *Client) SetTLSFingerprintFirefox() *Client
SetTLSFingerprintFirefox uses tls fingerprint of Firefox browser.
func (c *Client) SetTLSFingerprintIOS() *Client
SetTLSFingerprintIOS uses tls fingerprint of IOS.
func (c *Client) SetTLSFingerprintQQ() *Client
SetTLSFingerprintQQ uses tls fingerprint of QQ browser.
func (*Client) SetTLSFingerprintRandomized ¶ added in v3.36.1
func (c *Client) SetTLSFingerprintRandomized() *Client
SetTLSFingerprintRandomized uses randomized tls fingerprint.
func (c *Client) SetTLSFingerprintSafari() *Client
SetTLSFingerprintSafari uses tls fingerprint of Safari browser.
func (*Client) SetTLSHandshake ¶ added in v3.36.1
SetTLSHandshake set the custom tls handshake function, only valid for HTTP1 and HTTP2, not HTTP3, it specifies an optional dial function for tls handshake, it works even if a proxy is set, can be used to customize the tls fingerprint.
SetTimeout set timeout for requests fired from the client.
func (c *Client) SetUnixSocket(file string) *Client
SetUnixSocket set client to dial connection use unix socket. For example:
client.SetUnixSocket("/var/run/custom.sock")
func (c *Client) SetUserAgent(userAgent string) *Client
SetUserAgent set the "User-Agent" header for requests fired from the client.
SetXmlMarshal set the XML marshal function which will be used to marshal request body.
SetXmlUnmarshal set the XML unmarshal function which will be used to unmarshal response body.
func (c *Client) WrapRoundTrip(wrappers ...RoundTripWrapper) *Client
WrapRoundTrip adds a client middleware function that will give the caller an opportunity to wrap the underlying http.RoundTripper.
func (c *Client) WrapRoundTripFunc(funcs ...RoundTripWrapperFunc) *Client
WrapRoundTripFunc adds a client middleware function that will give the caller an opportunity to wrap the underlying http.RoundTripper.
type ContentDisposition ¶ added in v3.5.1
type ContentDisposition struct {
}
ContentDisposition represents parameters in `Content-Disposition` MIME header of multipart request.
func (*ContentDisposition) Add ¶ added in v3.5.1
Add adds a new key-value pair of Content-Disposition
type DownloadCallback func(info DownloadInfo)
DownloadCallback is the callback which will be invoked during response body download.
type DownloadInfo struct {
Response *[Response](#Response)
DownloadedSize [int64](/builtin#int64)}
DownloadInfo is the information for each DownloadCallback call.
DumpOptions controls the dump behavior.
func (do *DumpOptions) Clone() *DumpOptions
Clone return a copy of DumpOptions
type ErrorHook func(client *Client, req *Request, resp *Response, err error)
type FileUpload struct {
ParamName [string](/builtin#string)
FileName [string](/builtin#string)
GetFileContent [GetContentFunc](#GetContentFunc)
FileSize [int64](/builtin#int64)
ContentType [string](/builtin#string)
ExtraContentDisposition *[ContentDisposition](#ContentDisposition)}
FileUpload represents a "form-data" multipart
GetRetryIntervalFunc is a function that determines how long should sleep between retry attempts.
HttpRoundTripFunc is a http.RoundTripper implementation, which is a simple function.
RoundTrip implements http.RoundTripper.
HttpRoundTripWrapper is transport middleware function.
HttpRoundTripWrapperFunc is transport middleware function, more convenient than HttpRoundTripWrapper.
Logger is the abstract logging interface, gives control to the Req users, choice of the logger.
NewLogger create a Logger wraps the *log.Logger
type ParallelDownload struct {
}
func (pd *ParallelDownload) SetConcurrency(concurrency int) *ParallelDownload
func (pd *ParallelDownload) SetSegmentSize(segmentSize int64) *ParallelDownload
func (pd *ParallelDownload) SetTempRootDir(tempRootDir string) *ParallelDownload
RedirectPolicy represents the redirect policy for Client.
func AllowedDomainRedirectPolicy ¶
func AllowedDomainRedirectPolicy(hosts ...string) RedirectPolicy
AllowedDomainRedirectPolicy allows redirect only if the redirected domain match one of the domain that specified.
func AllowedHostRedirectPolicy(hosts ...string) RedirectPolicy
AllowedHostRedirectPolicy allows redirect only if the redirected host match one of the host that specified.
func AlwaysCopyHeaderRedirectPolicy(headers ...string) RedirectPolicy
AlwaysCopyHeaderRedirectPolicy ensures that the given sensitive headers will always be copied on redirect. By default, golang will copy all of the original request's headers on redirect, unless they're sensitive, like "Authorization" or "Www-Authenticate". Only send sensitive ones to the same origin, or subdomains thereof (https://go-review.googlesource.com/c/go/+/28930/) Check discussion: https://github.com/golang/go/issues/4800For example:
client.SetRedirectPolicy(req.AlwaysCopyHeaderRedirectPolicy("Authorization"))
func DefaultRedirectPolicy() RedirectPolicy
DefaultRedirectPolicy allows up to 10 redirects
func MaxRedirectPolicy(noOfRedirect int) RedirectPolicy
MaxRedirectPolicy specifies the max number of redirect
func NoRedirectPolicy() RedirectPolicy
NoRedirectPolicy disable redirect behaviour
func SameDomainRedirectPolicy ¶
func SameDomainRedirectPolicy() RedirectPolicy
SameDomainRedirectPolicy allows redirect only if the redirected domain is the same as original domain, e.g. redirect to "www.imroc.cc" from "imroc.cc" is allowed, but redirect to "google.com" is not allowed.
func SameHostRedirectPolicy() RedirectPolicy
SameHostRedirectPolicy allows redirect only if the redirected host is the same as original host, e.g. redirect to "www.imroc.cc" from "imroc.cc" is not the allowed.
Request struct is used to compose and fire individual request from req client. Request provides lots of chainable settings which can override client level settings.
func AddQueryParam(key, value string) *Request
AddQueryParam is a global wrapper methods which delegated to the default client, create a request and AddQueryParam for request.
AddQueryParams is a global wrapper methods which delegated to the default client, create a request and AddQueryParams for request.
func AddRetryCondition(condition RetryConditionFunc) *Request
AddRetryCondition is a global wrapper methods which delegated to the default client, create a request and AddRetryCondition for request.
func AddRetryHook(hook RetryHookFunc) *Request
AddRetryHook is a global wrapper methods which delegated to the default client, create a request and AddRetryHook for request.
func DisableForceChunkedEncoding() *Request
DisableForceChunkedEncoding is a global wrapper methods which delegated to the default client, create a request and DisableForceChunkedEncoding for request.
func DisableForceMultipart() *Request
DisableForceMultipart is a global wrapper methods which delegated to the default client, create a request and DisableForceMultipart for request.
func DisableTrace() *Request
DisableTrace is a global wrapper methods which delegated to the default client, create a request and DisableTrace for request.
func EnableCloseConnection() *Request
EnableCloseConnection is a global wrapper methods which delegated to the default client, create a request and EnableCloseConnection for request.
func EnableDump() *Request
EnableDump is a global wrapper methods which delegated to the default client, create a request and EnableDump for request.
EnableDumpTo is a global wrapper methods which delegated to the default client, create a request and EnableDumpTo for request.
func EnableDumpToFile(filename string) *Request
EnableDumpToFile is a global wrapper methods which delegated to the default client, create a request and EnableDumpToFile for request.
func EnableDumpWithoutBody ¶
func EnableDumpWithoutBody() *Request
EnableDumpWithoutBody is a global wrapper methods which delegated to the default client, create a request and EnableDumpWithoutBody for request.
func EnableDumpWithoutHeader() *Request
EnableDumpWithoutHeader is a global wrapper methods which delegated to the default client, create a request and EnableDumpWithoutHeader for request.
func EnableDumpWithoutRequest() *Request
EnableDumpWithoutRequest is a global wrapper methods which delegated to the default client, create a request and EnableDumpWithoutRequest for request.
func EnableDumpWithoutRequestBody ¶ added in v3.1.0
func EnableDumpWithoutRequestBody() *Request
EnableDumpWithoutRequestBody is a global wrapper methods which delegated to the default client, create a request and EnableDumpWithoutRequestBody for request.
func EnableDumpWithoutResponse() *Request
EnableDumpWithoutResponse is a global wrapper methods which delegated to the default client, create a request and EnableDumpWithoutResponse for request.
func EnableDumpWithoutResponseBody ¶ added in v3.1.0
func EnableDumpWithoutResponseBody() *Request
EnableDumpWithoutResponseBody is a global wrapper methods which delegated to the default client, create a request and EnableDumpWithoutResponseBody for request.
func EnableForceChunkedEncoding() *Request
EnableForceChunkedEncoding is a global wrapper methods which delegated to the default client, create a request and EnableForceChunkedEncoding for request.
func EnableForceMultipart() *Request
EnableForceMultipart is a global wrapper methods which delegated to the default client, create a request and EnableForceMultipart for request.
func EnableTrace() *Request
EnableTrace is a global wrapper methods which delegated to the default client, create a request and EnableTrace for request.
func NewRequest() *Request
NewRequest is a global wrapper methods which delegated to the default client's Client.NewRequest.
R is a global wrapper methods which delegated to the default client's Client.R().
func SetBasicAuth(username, password string) *Request
SetBasicAuth is a global wrapper methods which delegated to the default client, create a request and SetBasicAuth for request.
func SetBearerAuthToken(token string) *Request
SetBearerAuthToken is a global wrapper methods which delegated to the default client, create a request and SetBearerAuthToken for request.
func SetBody ¶
func SetBody(body any) *Request
SetBody is a global wrapper methods which delegated to the default client, create a request and SetBody for request.
func SetBodyBytes ¶
func SetBodyBytes(body []byte) *Request
SetBodyBytes is a global wrapper methods which delegated to the default client, create a request and SetBodyBytes for request.
func SetBodyJsonBytes ¶
func SetBodyJsonBytes(body []byte) *Request
SetBodyJsonBytes is a global wrapper methods which delegated to the default client, create a request and SetBodyJsonBytes for request.
func SetBodyJsonMarshal ¶
func SetBodyJsonMarshal(v any) *Request
SetBodyJsonMarshal is a global wrapper methods which delegated to the default client, create a request and SetBodyJsonMarshal for request.
func SetBodyJsonString ¶
func SetBodyJsonString(body string) *Request
SetBodyJsonString is a global wrapper methods which delegated to the default client, create a request and SetBodyJsonString for request.
func SetBodyString ¶
SetBodyString is a global wrapper methods which delegated to the default client, create a request and SetBodyString for request.
func SetBodyXmlBytes ¶
func SetBodyXmlBytes(body []byte) *Request
SetBodyXmlBytes is a global wrapper methods which delegated to the default client, create a request and SetBodyXmlBytes for request.
func SetBodyXmlMarshal ¶
func SetBodyXmlMarshal(v any) *Request
SetBodyXmlMarshal is a global wrapper methods which delegated to the default client, create a request and SetBodyXmlMarshal for request.
func SetBodyXmlString ¶
func SetBodyXmlString(body string) *Request
SetBodyXmlString is a global wrapper methods which delegated to the default client, create a request and SetBodyXmlString for request.
func SetContentType ¶
func SetContentType(contentType string) *Request
SetContentType is a global wrapper methods which delegated to the default client, create a request and SetContentType for request.
SetContext is a global wrapper methods which delegated to the default client, create a request and SetContext for request.
SetCookies is a global wrapper methods which delegated to the default client, create a request and SetCookies for request.
func SetDigestAuth(username, password string) *Request
SetDigestAuth is a global wrapper methods which delegated to the default client, create a request and SetDigestAuth for request.
func SetDownloadCallback(callback DownloadCallback) *Request
SetDownloadCallback is a global wrapper methods which delegated to the default client, create a request and SetDownloadCallback for request.
func SetDownloadCallbackWithInterval(callback DownloadCallback, minInterval time.Duration) *Request
SetDownloadCallbackWithInterval is a global wrapper methods which delegated to the default client, create a request and SetDownloadCallbackWithInterval for request.
func SetDumpOptions(opt *DumpOptions) *Request
SetDumpOptions is a global wrapper methods which delegated to the default client, create a request and SetDumpOptions for request.
func SetError(error any) *Request
SetError is a global wrapper methods which delegated to the default client, create a request and SetErrorResult for request.
Deprecated: Use SetErrorResult instead.
func SetErrorResult(error any) *Request
SetErrorResult is a global wrapper methods which delegated to the default client, create a request and SetErrorResult for request.
func SetFile(paramName, filePath string) *Request
SetFile is a global wrapper methods which delegated to the default client, create a request and SetFile for request.
func SetFileBytes(paramName, filename string, content []byte) *Request
SetFileBytes is a global wrapper methods which delegated to the default client, create a request and SetFileBytes for request.
SetFileReader is a global wrapper methods which delegated to the default client, create a request and SetFileReader for request.
func SetFileUpload(f ...FileUpload) *Request
SetFileUpload is a global wrapper methods which delegated to the default client, create a request and SetFileUpload for request.
SetFiles is a global wrapper methods which delegated to the default client, create a request and SetFiles for request.
SetFormData is a global wrapper methods which delegated to the default client, create a request and SetFormData for request.
SetFormDataAnyType is a global wrapper methods which delegated to the default client, create a request and SetFormDataAnyType for request.
SetFormDataFromValues is a global wrapper methods which delegated to the default client, create a request and SetFormDataFromValues for request.
func SetHeader(key, value string) *Request
SetHeader is a global wrapper methods which delegated to the default client, create a request and SetHeader for request.
func SetHeaderOrder(keys ...string) *Request
SetHeaderOrder is a global wrapper methods which delegated to the default client, create a request and SetHeaderOrder for request.
SetHeaders is a global wrapper methods which delegated to the default client, create a request and SetHeaders for request.
func SetOrderedFormData(kvs ...string) *Request
SetOrderedFormData is a global wrapper methods which delegated to the default client, create a request and SetOrderedFormData for request.
SetOutput is a global wrapper methods which delegated to the default client, create a request and SetOutput for request.
SetOutputFile is a global wrapper methods which delegated to the default client, create a request and SetOutputFile for request.
func SetPathParam(key, value string) *Request
SetPathParam is a global wrapper methods which delegated to the default client, create a request and SetPathParam for request.
SetPathParams is a global wrapper methods which delegated to the default client, create a request and SetPathParams for request.
func SetPseudoHeaderOrder(keys ...string) *Request
SetPseudoHeaderOrder is a global wrapper methods which delegated to the default client, create a request and SetPseudoHeaderOrder for request.
func SetQueryParam(key, value string) *Request
SetQueryParam is a global wrapper methods which delegated to the default client, create a request and SetQueryParam for request.
SetQueryParams is a global wrapper methods which delegated to the default client, create a request and SetQueryParams for request.
func SetQueryParamsAnyType(params map[string]any) *Request
SetQueryParamsAnyType is a global wrapper methods which delegated to the default client, create a request and SetQueryParamsAnyType for request.
func SetQueryParamsFromStruct(v any) *Request
SetQueryParamsFromStruct is a global wrapper methods which delegated to the default client, create a request and SetQueryParamsFromStruct for request.
func SetQueryParamsFromValues(params url.Values) *Request
SetQueryParamsFromValues is a global wrapper methods which delegated to the default client, create a request and SetQueryParamsFromValues for request.
func SetQueryString(query string) *Request
SetQueryString is a global wrapper methods which delegated to the default client, create a request and SetQueryString for request.
func SetResult(result any) *Request
SetResult is a global wrapper methods which delegated to the default client, create a request and SetSuccessResult for request.
Deprecated: Use SetSuccessResult instead.
SetRetryBackoffInterval is a global wrapper methods which delegated to the default client, create a request and SetRetryBackoffInterval for request.
func SetRetryCondition(condition RetryConditionFunc) *Request
SetRetryCondition is a global wrapper methods which delegated to the default client, create a request and SetRetryCondition for request.
func SetRetryCount(count int) *Request
SetRetryCount is a global wrapper methods which delegated to the default client, create a request and SetRetryCount for request.
SetRetryFixedInterval is a global wrapper methods which delegated to the default client, create a request and SetRetryFixedInterval for request.
func SetRetryHook(hook RetryHookFunc) *Request
SetRetryHook is a global wrapper methods which delegated to the default client, create a request and SetRetryHook for request.
func SetRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Request
SetRetryInterval is a global wrapper methods which delegated to the default client, create a request and SetRetryInterval for request.
func SetSuccessResult(result any) *Request
SetSuccessResult is a global wrapper methods which delegated to the default client, create a request and SetSuccessResult for request.
SetURL is a global wrapper methods which delegated to the default client, create a request and SetURL for request.
func SetUploadCallback(callback UploadCallback) *Request
SetUploadCallback is a global wrapper methods which delegated to the default client, create a request and SetUploadCallback for request.
func SetUploadCallbackWithInterval(callback UploadCallback, minInterval time.Duration) *Request
SetUploadCallbackWithInterval is a global wrapper methods which delegated to the default client, create a request and SetUploadCallbackWithInterval for request.
func (r *Request) AddQueryParam(key, value string) *Request
AddQueryParam add a URL query parameter for the request.
AddQueryParams add one or more values of specified URL query parameter for the request.
func (r *Request) AddRetryCondition(condition RetryConditionFunc) *Request
AddRetryCondition adds a retry condition, which determines whether the request should retry.
func (r *Request) AddRetryHook(hook RetryHookFunc) *Request
AddRetryHook adds a retry hook which will be executed before a retry.
Context method returns the Context if its already set in request otherwise it creates new one using `context.Background()`.
Delete fires http request with DELETE method and the specified URL.
func (r *Request) DisableAutoReadResponse() *Request
DisableAutoReadResponse disable read response body automatically (enabled by default).
func (r *Request) DisableForceChunkedEncoding() *Request
DisableForceChunkedEncoding disables force using chunked encoding when uploading.
func (r *Request) DisableForceMultipart() *Request
DisableForceMultipart disables force using multipart to upload form data.
func (r *Request) DisableTrace() *Request
DisableTrace disables trace.
Do fires http request, 0 or 1 context is allowed, and returns the *Response which is always not nil, and Response.Err is not nil if error occurs.
func (r *Request) EnableAutoReadResponse() *Request
EnableAutoReadResponse enable read response body automatically (enabled by default).
func (r *Request) EnableCloseConnection() *Request
EnableCloseConnection closes the connection after sending this request and reading its response if set to true in HTTP/1.1 and HTTP/2.
Setting this field prevents reuse of TCP connections between requests to the same hosts event if EnableKeepAlives() were called.
func (r *Request) EnableDump() *Request
EnableDump enables dump, including all content for the request and response by default.
EnableDumpTo enables dump and save to the specified io.Writer.
func (r *Request) EnableDumpToFile(filename string) *Request
EnableDumpToFile enables dump and save to the specified filename.
func (*Request) EnableDumpWithoutBody ¶
func (r *Request) EnableDumpWithoutBody() *Request
EnableDumpWithoutBody enables dump only header for the request and response.
func (r *Request) EnableDumpWithoutHeader() *Request
EnableDumpWithoutHeader enables dump only Body for the request and response.
func (r *Request) EnableDumpWithoutRequest() *Request
EnableDumpWithoutRequest enables dump only response.
func (*Request) EnableDumpWithoutRequestBody ¶ added in v3.1.0
func (r *Request) EnableDumpWithoutRequestBody() *Request
EnableDumpWithoutRequestBody enables dump with request Body excluded, can be used in upload request to avoid dump the unreadable binary content.
func (r *Request) EnableDumpWithoutResponse() *Request
EnableDumpWithoutResponse enables dump only request.
func (*Request) EnableDumpWithoutResponseBody ¶ added in v3.1.0
func (r *Request) EnableDumpWithoutResponseBody() *Request
EnableDumpWithoutResponseBody enables dump with response Body excluded, can be used in download request to avoid dump the unreadable binary content.
func (r *Request) EnableForceChunkedEncoding() *Request
EnableForceChunkedEncoding enables force using chunked encoding when uploading.
func (r *Request) EnableForceMultipart() *Request
EnableForceMultipart enables force using multipart to upload form data.
func (r *Request) EnableTrace() *Request
EnableTrace enables trace (http3 currently does not support trace).
Get fires http request with GET method and the specified URL.
func (r *Request) GetClient() *Client
GetClient returns the current client used by request.
func (r *Request) GetContextData(key any) any
GetContextData returns the context data of specified key, which set by SetContextData.
Head fires http request with HEAD method and the specified URL.
func (r *Request) HeaderToString() string
HeaderToString get all header as string.
MustDelete like Delete, panic if error happens, should only be used to test without error handling.
MustGet like Get, panic if error happens, should only be used to test without error handling.
MustHead like Head, panic if error happens, should only be used to test without error handling.
MustOptions like Options, panic if error happens, should only be used to test without error handling.
MustPatch like Patch, panic if error happens, should only be used to test without error handling.
MustPost like Post, panic if error happens. should only be used to test without error handling.
MustPut like Put, panic if error happens, should only be used to test without error handling.
func (r *Request) OnAfterResponse(m ResponseMiddleware) *Request
OnAfterResponse add a response middleware which hooks after response received.
Options fires http request with OPTIONS method and the specified URL.
Patch fires http request with PATCH method and the specified URL.
Post fires http request with POST method and the specified URL.
Put fires http request with PUT method and the specified URL.
Send fires http request with specified method and url, returns the *Response which is always not nil, and the error is not nil if error occurs.
func (r *Request) SetBasicAuth(username, password string) *Request
SetBasicAuth set basic auth for the request.
func (r *Request) SetBearerAuthToken(token string) *Request
SetBearerAuthToken set bearer auth token for the request.
func (*Request) SetBody ¶
func (r *Request) SetBody(body any) *Request
SetBody set the request Body, accepts string, []byte, io.Reader, map and struct.
func (*Request) SetBodyBytes ¶
func (r *Request) SetBodyBytes(body []byte) *Request
SetBodyBytes set the request Body as []byte.
func (*Request) SetBodyJsonBytes ¶
func (r *Request) SetBodyJsonBytes(body []byte) *Request
SetBodyJsonBytes set the request Body as []byte and set Content-Type header as "application/json; charset=utf-8"
func (*Request) SetBodyJsonMarshal ¶
func (r *Request) SetBodyJsonMarshal(v any) *Request
SetBodyJsonMarshal set the request Body that marshaled from object, and set Content-Type header as "application/json; charset=utf-8"
func (*Request) SetBodyJsonString ¶
func (r *Request) SetBodyJsonString(body string) *Request
SetBodyJsonString set the request Body as string and set Content-Type header as "application/json; charset=utf-8"
func (*Request) SetBodyString ¶
func (r *Request) SetBodyString(body string) *Request
SetBodyString set the request Body as string.
func (*Request) SetBodyXmlBytes ¶
func (r *Request) SetBodyXmlBytes(body []byte) *Request
SetBodyXmlBytes set the request Body as []byte and set Content-Type header as "text/xml; charset=utf-8"
func (*Request) SetBodyXmlMarshal ¶
func (r *Request) SetBodyXmlMarshal(v any) *Request
SetBodyXmlMarshal set the request Body that marshaled from object, and set Content-Type header as "text/xml; charset=utf-8"
func (*Request) SetBodyXmlString ¶
func (r *Request) SetBodyXmlString(body string) *Request
SetBodyXmlString set the request Body as string and set Content-Type header as "text/xml; charset=utf-8"
func (r *Request) SetClient(client *Client) *Request
SetClient change the client of request dynamically.
func (*Request) SetContentType ¶
func (r *Request) SetContentType(contentType string) *Request
SetContentType set the `Content-Type` for the request.
SetContext method sets the context.Context for current Request. It allows to interrupt the request execution if ctx.Done() channel is closed. See https://blog.golang.org/context article and the "context" package documentation.
Attention: make sure call SetContext before EnableDumpXXX if you want to dump at the request level.
func (r *Request) SetContextData(key, val any) *Request
SetContextData sets the key-value pair data for current Request, so you can access some extra context info for current Request in hook or middleware.
SetCookies set http cookies for the request.
func (r *Request) SetDigestAuth(username, password string) *Request
SetDigestAuth sets the Digest Access auth scheme for the HTTP request. If a server responds with 401 and sends a Digest challenge in the WWW-Authenticate Header, the request will be resent with the appropriate Authorization Header.
For Example: To set the Digest scheme with username "roc" and password "123456"
client.R().SetDigestAuth("roc", "123456")
Information about Digest Access Authentication can be found in RFC7616:
https://datatracker.ietf.org/doc/html/rfc7616
Deprecated: Use Client.SetCommonDigestAuth instead. Request level digest auth is not recommended,
func (r *Request) SetDownloadCallback(callback DownloadCallback) *Request
SetDownloadCallback set the DownloadCallback which will be invoked at least every 200ms during file upload, usually used to show download progress.
func (r *Request) SetDownloadCallbackWithInterval(callback DownloadCallback, minInterval time.Duration) *Request
SetDownloadCallbackWithInterval set the DownloadCallback which will be invoked at least every `minInterval` during file upload, usually used to show download progress.
func (r *Request) SetDumpOptions(opt *DumpOptions) *Request
SetDumpOptions sets DumpOptions at request level.
func (r *Request) SetError(err any) *Request
SetError set the result that response body will be unmarshalled to if no error occurs and Response.ResultState() returns ErrorState, by default it requires HTTP status `code >= 400`, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
Deprecated: Use SetErrorResult result.
func (r *Request) SetErrorResult(err any) *Request
SetErrorResult set the result that response body will be unmarshalled to if no error occurs and Response.ResultState() returns ErrorState, by default it requires HTTP status `code >= 400`, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
func (r *Request) SetFile(paramName, filePath string) *Request
SetFile set up a multipart form from file path to upload, which read file from filePath automatically to upload.
func (r *Request) SetFileBytes(paramName, filename string, content []byte) *Request
SetFileBytes set up a multipart form with given []byte to upload.
SetFileReader set up a multipart form with a reader to upload file.
func (r *Request) SetFileUpload(uploads ...FileUpload) *Request
SetFileUpload set the fully customized multipart file upload options.
SetFiles set up a multipart form from a map to upload, which key is the parameter name, and value is the file path.
SetFormData set the form data from a map, will not been used if request method does not allow payload.
func (r *Request) SetFormDataAnyType(data map[string]any) *Request
SetFormDataAnyType set the form data from a map, which value could be any type, will convert to string automatically. It will not been used if request method does not allow payload.
SetFormDataFromValues set the form data from url.Values, will not been used if request method does not allow payload.
func (r *Request) SetHeader(key, value string) *Request
SetHeader set a header for the request.
func (r *Request) SetHeaderNonCanonical(key, value string) *Request
SetHeaderNonCanonical set a header for the request which key is a non-canonical key (keep case unchanged), only valid for HTTP/1.1.
func (r *Request) SetHeaderOrder(keys ...string) *Request
SetHeaderOrder set the order of the http header (case-insensitive). For example:
client.R().SetHeaderOrder( "custom-header", "cookie", "user-agent", "accept-encoding", )
SetHeaders set headers from a map for the request.
SetHeadersNonCanonical set headers from a map for the request which key is a non-canonical key (keep case unchanged), only valid for HTTP/1.1.
func (r *Request) SetOrderedFormData(kvs ...string) *Request
SetOrderedFormData set the ordered form data from key-values pairs.
SetOutput set the io.Writer that response Body will be downloaded to.
func (r *Request) SetOutputFile(file string) *Request
SetOutputFile set the file that response Body will be downloaded to.
func (r *Request) SetPathParam(key, value string) *Request
SetPathParam set a URL path parameter for the request.
SetPathParams set URL path parameters from a map for the request.
func (r *Request) SetPseudoHeaderOrder(keys ...string) *Request
SetPseudoHeaderOrder set the order of the pseudo http header (case-insensitive). Note this is only valid for http2 and http3. For example:
client.R().SetPseudoHeaderOrder( ":scheme", ":authority", ":path", ":method", )
func (r *Request) SetQueryParam(key, value string) *Request
SetQueryParam set an URL query parameter for the request.
SetQueryParams set URL query parameters from a map for the request.
func (r *Request) SetQueryParamsAnyType(params map[string]any) *Request
SetQueryParamsAnyType set URL query parameters from a map for the request. The value of map is any type, will be convert to string automatically.
func (r *Request) SetQueryParamsFromStruct(v any) *Request
SetQueryParamsFromStruct sets query parameters from a struct using go-querystring. This method provides a higher-level abstraction by allowing users to directly pass a struct to configure query parameters. The struct should use `url` tags to specify parameter names.
SetQueryParamsFromValues sets query parameters from a url.Values map. This method allows direct configuration of query parameters from url.Values, which is commonly used with libraries like go-querystring.
func (r *Request) SetQueryString(query string) *Request
SetQueryString set URL query parameters for the request using raw query string.
func (r *Request) SetResult(result any) *Request
SetResult set the result that response Body will be unmarshalled to if no error occurs and Response.ResultState() returns SuccessState, by default it requires HTTP status `code >= 200 && code <= 299`, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
Deprecated: Use SetSuccessResult instead.
func (r *Request) SetRetryCondition(condition RetryConditionFunc) *Request
SetRetryCondition sets the retry condition, which determines whether the request should retry. It will override other retry conditions if any been added before (including client-level retry conditions).
func (r *Request) SetRetryCount(count int) *Request
SetRetryCount enables retry and set the maximum retry count. It will retry infinitely if count is negative.
SetRetryFixedInterval set retry to use a fixed interval.
func (r *Request) SetRetryHook(hook RetryHookFunc) *Request
SetRetryHook set the retry hook which will be executed before a retry. It will override other retry hooks if any been added before (including client-level retry hooks).
func (r *Request) SetRetryInterval(getRetryIntervalFunc GetRetryIntervalFunc) *Request
SetRetryInterval sets the custom GetRetryIntervalFunc, you can use this to implement your own backoff retry algorithm. For example:
req.SetRetryInterval(func(resp *req.Response, attempt int) time.Duration { sleep := 0.01 * math.Exp2(float64(attempt)) return time.Duration(math.Min(2, sleep)) * time.Second })
func (r *Request) SetSuccessResult(result any) *Request
SetSuccessResult set the result that response Body will be unmarshalled to if no error occurs and Response.ResultState() returns SuccessState, by default it requires HTTP status `code >= 200 && code <= 299`, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
SetURL set the url for request.
func (r *Request) SetUploadCallback(callback UploadCallback) *Request
SetUploadCallback set the UploadCallback which will be invoked at least every 200ms during file upload, usually used to show upload progress.
func (r *Request) SetUploadCallbackWithInterval(callback UploadCallback, minInterval time.Duration) *Request
SetUploadCallbackWithInterval set the UploadCallback which will be invoked at least every `minInterval` during file upload, usually used to show upload progress.
func (r *Request) TraceInfo() TraceInfo
TraceInfo returns the trace information, only available if trace is enabled (see Request.EnableTrace and Client.EnableTraceAll).
type RequestMiddleware func(client *Client, req *Request) error
RequestMiddleware type is for request middleware, called before a request is sent
Response is the http response.
Delete is a global wrapper methods which delegated to the default client, create a request and Delete for request.
Get is a global wrapper methods which delegated to the default client, create a request and Get for request.
Head is a global wrapper methods which delegated to the default client, create a request and Head for request.
MustDelete is a global wrapper methods which delegated to the default client, create a request and MustDelete for request.
MustGet is a global wrapper methods which delegated to the default client, create a request and MustGet for request.
MustHead is a global wrapper methods which delegated to the default client, create a request and MustHead for request.
MustOptions is a global wrapper methods which delegated to the default client, create a request and MustOptions for request.
MustPatch is a global wrapper methods which delegated to the default client, create a request and MustPatch for request.
MustPost is a global wrapper methods which delegated to the default client, create a request and Get for request.
MustPut is a global wrapper methods which delegated to the default client, create a request and MustPut for request.
Options is a global wrapper methods which delegated to the default client, create a request and Options for request.
Patch is a global wrapper methods which delegated to the default client, create a request and Patch for request.
Post is a global wrapper methods which delegated to the default client, create a request and Post for request.
Put is a global wrapper methods which delegated to the default client, create a request and Put for request.
func (r *Response) Bytes() []byte
Bytes return the response body as []bytes that have already been read, could be nil if not read, the following cases are already read:
- `Request.SetResult` or `Request.SetError` is called.
- `Client.DisableAutoReadResponse` and `Request.DisableAutoReadResponse` is not called, and also `Request.SetOutput` and `Request.SetOutputFile` is not called.
Dump return the string content that have been dumped for the request. `Request.Dump` or `Request.DumpXXX` MUST have been called.
func (r *Response) Error() any
Error returns the automatically unmarshalled object when Request.SetErrorResult or Client.SetCommonErrorResult is called, and ResultState returns ErrorState. Otherwise, return nil.
Deprecated: Use ErrorResult instead.
func (r *Response) ErrorResult() any
ErrorResult returns the automatically unmarshalled object when Request.SetErrorResult or Client.SetCommonErrorResult is called, and ResultState returns ErrorState. Otherwise, return nil.
func (*Response) GetContentType ¶
func (r *Response) GetContentType() string
GetContentType return the `Content-Type` header value.
GetHeader returns the response header value by key.
GetHeaderValues returns the response header values by key.
GetStatus returns the response status.
func (r *Response) GetStatusCode() int
GetStatusCode returns the response status code.
func (r *Response) HeaderToString() string
HeaderToString get all header as string.
Into unmarshalls response body into the specified object according to response `Content-Type`.
func (r *Response) IsError() bool
IsError method returns true if no error occurs and HTTP status `code >= 400` by default, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
Deprecated: Use IsErrorState instead.
func (r *Response) IsErrorState() bool
IsErrorState method returns true if no error occurs and HTTP status `code >= 400` by default, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
func (r *Response) IsSuccess() bool
IsSuccess method returns true if no error occurs and HTTP status `code >= 200 and <= 299` by default, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
Deprecated: Use IsSuccessState instead.
func (r *Response) IsSuccessState() bool
IsSuccessState method returns true if no error occurs and HTTP status `code >= 200 and <= 299` by default, you can also use Client.SetResultStateCheckFunc to customize the result state check logic.
ReceivedAt returns the timestamp that response we received.
func (r *Response) Result() any
Result returns the automatically unmarshalled object if Request.SetSuccessResult is called and ResultState returns SuccessState. Otherwise, return nil.
Deprecated: Use SuccessResult instead.
func (r *Response) ResultState() ResultState
ResultState returns the result state. By default, it returns SuccessState if HTTP status `code >= 200 && code <= 299`, and returns ErrorState if HTTP status `code >= 400`, otherwise returns UnknownState. You can also use Client.SetResultStateCheckFunc to customize the result state check logic.
func (*Response) SetBody ¶ added in v3.49.0
func (r *Response) SetBody(body []byte)
Set response body with byte array content
func (*Response) SetBodyString ¶ added in v3.49.0
func (r *Response) SetBodyString(body string)
Set response body with string content
String returns the response body as string that have already been read, could be nil if not read, the following cases are already read:
- `Request.SetResult` or `Request.SetError` is called.
- `Client.DisableAutoReadResponse` and `Request.DisableAutoReadResponse` is not called, and also `Request.SetOutput` and `Request.SetOutputFile` is not called.
func (r *Response) SuccessResult() any
SuccessResult returns the automatically unmarshalled object if Request.SetSuccessResult is called and ResultState returns SuccessState. Otherwise, return nil.
ToBytes returns the response body as []byte, read body if not have been read.
ToString returns the response body as string, read body if not have been read.
TotalTime returns the total time of the request, from request we sent to response we received.
func (r *Response) TraceInfo() TraceInfo
TraceInfo returns the TraceInfo from Request.
Unmarshal unmarshalls response body into the specified object according to response `Content-Type`.
UnmarshalJson unmarshalls JSON response body into the specified object.
UnmarshalXml unmarshalls XML response body into the specified object.
type ResponseMiddleware func(client *Client, resp *Response) error
ResponseMiddleware type is for response middleware, called after a response has been received
ResultState represents the state of the result.
const (
SuccessState [ResultState](#ResultState) = [iota](/builtin#iota)
ErrorState
UnknownState)
type RetryConditionFunc func(resp *Response, err error) bool
RetryConditionFunc is a retry condition, which determines whether the request should retry.
type RetryHookFunc func(resp *Response, err error)
RetryHookFunc is a retry hook which will be executed before a retry.
type RoundTripFunc func(req *Request) (resp *Response, err error)
RoundTripFunc is a RoundTripper implementation, which is a simple function.
RoundTrip implements RoundTripper.
type RoundTripWrapper func(rt RoundTripper) RoundTripper
RoundTripWrapper is client middleware function.
type RoundTripWrapperFunc func(rt RoundTripper) RoundTripFunc
RoundTripWrapperFunc is client middleware function, more convenient than RoundTripWrapper.
type RoundTripper interface { RoundTrip(Request) (Response, error) }
RoundTripper is the interface of req's Client.
TraceInfo represents the trace information.
Blame return the human-readable reason of why request is slowing.
String return the details of trace information.
Transport is an implementation of http.RoundTripper that supports HTTP, HTTPS, and HTTP proxies (for either HTTP or HTTPS with CONNECT).
By default, Transport caches connections for future reuse. This may leave many open connections when accessing many hosts. This behavior can be managed using Transport's CloseIdleConnections method and the MaxIdleConnsPerHost and DisableKeepAlives fields.
Transports should be reused instead of created as needed. Transports are safe for concurrent use by multiple goroutines.
A Transport is a low-level primitive for making HTTP and HTTPS requests. For high-level functionality, such as cookies and redirects, see Client.
Transport uses HTTP/1.1 for HTTP URLs and either HTTP/1.1 or HTTP/2 for HTTPS URLs, depending on whether the server supports HTTP/2, and how the Transport is configured. The DefaultTransport supports HTTP/2. To explicitly enable HTTP/2 on a transport, use golang.org/x/net/http2 and call ConfigureTransport. See the package docs for more about HTTP/2.
Responses with status codes in the 1xx range are either handled automatically (100 expect-continue) or ignored. The one exception is HTTP status code 101 (Switching Protocols), which is considered a terminal status and returned by RoundTrip. To see the ignored 1xx responses, use the httptrace trace package's ClientTrace.Got1xxResponse.
Transport only retries a request upon encountering a network error if the request is idempotent and either has no body or has its Request.GetBody defined. HTTP requests are considered idempotent if they have HTTP methods GET, HEAD, OPTIONS, or TRACE; or if their Header map contains an "Idempotency-Key" or "X-Idempotency-Key" entry. If the idempotency key value is a zero-length slice, the request is treated as idempotent but the header is not sent on the wire.
func NewTransport() *Transport
NewTransport is an alias of T
CancelRequest cancels an in-flight request by closing its connection. CancelRequest should only be called after Transport.RoundTrip has returned.
Deprecated: Use [Request.WithContext] to create a request with a cancelable context instead. CancelRequest cannot cancel HTTP/2 requests. This may become a no-op in a future release of Go.
func (t *Transport) Clone() *Transport
Clone returns a deep copy of t's exported fields.
func (t *Transport) CloseIdleConnections()
CloseIdleConnections closes any connections which were previously connected from previous requests but are now sitting idle in a "keep-alive" state. It does not interrupt any connections currently in use.
func (t *Transport) DisableAutoDecode() *Transport
DisableAutoDecode disable auto-detect charset and decode to utf-8 (enabled by default).
func (t *Transport) DisableDump()
DisableDump disables the dump.
func (t *Transport) DisableForceHttpVersion() *Transport
DisableForceHttpVersion disable force using specified http version (disabled by default).
func (t *Transport) DisableH2C() *Transport
DisableH2C disables HTTP2 over TCP without TLS.
func (t *Transport) DisableHTTP3()
func (t *Transport) EnableAutoDecode() *Transport
EnableAutoDecode enable auto-detect charset and decode to utf-8 (enabled by default).
func (t *Transport) EnableDump(opt *DumpOptions)
EnableDump enables the dump for all requests with specified dump options.
func (t *Transport) EnableForceHTTP1() *Transport
EnableForceHTTP1 enable force using HTTP1 (disabled by default).
func (t *Transport) EnableForceHTTP2() *Transport
EnableForceHTTP2 enable force using HTTP2 for https requests (disabled by default).
func (t *Transport) EnableForceHTTP3() *Transport
EnableForceHTTP3 enable force using HTTP3 for https requests (disabled by default).
func (t *Transport) EnableH2C() *Transport
EnableH2C enables HTTP2 over TCP without TLS.
func (t *Transport) EnableHTTP3()
func (t *Transport) GetMaxIdleConns() int
GetMaxIdleConns returns MaxIdleConns.
RoundTrip implements the RoundTripper interface.
For higher-level HTTP client support (such as handling of cookies and redirects), see Get, Post, and the Client type.
Like the RoundTripper interface, the error types returned by RoundTrip are unspecified.
func (*Transport) SetAutoDecodeAllContentType ¶ added in v3.14.0
func (t *Transport) SetAutoDecodeAllContentType() *Transport
SetAutoDecodeAllContentType enable try auto-detect charset and decode all content type to utf-8.
func (*Transport) SetAutoDecodeContentType ¶ added in v3.14.0
func (t *Transport) SetAutoDecodeContentType(contentTypes ...string)
SetAutoDecodeContentType set the content types that will be auto-detected and decode to utf-8 (e.g. "json", "xml", "html", "text").
func (*Transport) SetAutoDecodeContentTypeFunc ¶ added in v3.14.0
func (t *Transport) SetAutoDecodeContentTypeFunc(fn func(contentType string) bool) *Transport
SetAutoDecodeContentTypeFunc set the function that determines whether the specified `Content-Type` should be auto-detected and decode to utf-8.
func (t *Transport) SetDebug(debugf func(format string, v ...any)) *Transport
SetDebug set the optional debug function.
SetDial set the custom DialContext function, only valid for HTTP1 and HTTP2, which specifies the dial function for creating unencrypted TCP connections. If it is nil, then the transport dials using package net.
The dial function runs concurrently with calls to RoundTrip. A RoundTrip call that initiates a dial may end up using a connection dialed previously when the earlier connection becomes idle before the later dial function completes.
SetDialTLS set the custom DialTLSContext function, only valid for HTTP1 and HTTP2, which specifies an optional dial function for creating TLS connections for non-proxied HTTPS requests (proxy will not work if set).
If it is nil, DialContext and TLSClientConfig are used.
If it is set, the function that set in SetDial is not used for HTTPS requests and the TLSClientConfig and TLSHandshakeTimeout are ignored. The returned net.Conn is assumed to already be past the TLS handshake.
SetExpectContinueTimeout set the ExpectContinueTimeout, if non-zero, specifies the amount of time to wait for a server's first response headers after fully writing the request headers if the request has an "Expect: 100-continue" header. Zero means no timeout and causes the body to be sent immediately, without waiting for the server to approve. This time does not include the time to send the request header.
SetGetProxyConnectHeader set the GetProxyConnectHeader, which optionally specifies a func to return headers to send to proxyURL during a CONNECT request to the ip:port target. If it returns an error, the Transport's RoundTrip fails with that error. It can return (nil, nil) to not add headers. If GetProxyConnectHeader is non-nil, ProxyConnectHeader is ignored.
func (t *Transport) SetHTTP2ConnectionFlow(flow uint32) *Transport
SetHTTP2ConnectionFlow set the default http2 connection flow, which is the increment value of initial WINDOW_UPDATE frame.
SetHTTP2HeaderPriority set the header priority param.
func (t *Transport) SetHTTP2MaxHeaderListSize(max uint32) *Transport
SetHTTP2MaxHeaderListSize set the http2 MaxHeaderListSize, which is the http2 SETTINGS_MAX_HEADER_LIST_SIZE to send in the initial settings frame. It is how many bytes of response headers are allowed. Unlike the http2 spec, zero here means to use a default limit (currently 10MB). If you actually want to advertise an unlimited value to the peer, Transport interprets the highest possible value here (0xffffffff or 1<<32-1) to mean no limit.
SetHTTP2PingTimeout set the http2 PingTimeout, which is the timeout after which the connection will be closed if a response to Ping is not received. Defaults to 15s
SetHTTP2PriorityFrames set the ordered http2 priority frames.
SetHTTP2ReadIdleTimeout set the http2 ReadIdleTimeout, which is the timeout after which a health check using ping frame will be carried out if no frame is received on the connection. Note that a ping response will is considered a received frame, so if there is no other traffic on the connection, the health check will be performed every ReadIdleTimeout interval. If zero, no health check is performed.
SetHTTP2SettingsFrame set the ordered http2 settings frame.
func (t *Transport) SetHTTP2StrictMaxConcurrentStreams(strict bool) *Transport
SetHTTP2StrictMaxConcurrentStreams set the http2 StrictMaxConcurrentStreams, which controls whether the server's SETTINGS_MAX_CONCURRENT_STREAMS should be respected globally. If false, new TCP connections are created to the server as needed to keep each under the per-connection SETTINGS_MAX_CONCURRENT_STREAMS limit. If true, the server's SETTINGS_MAX_CONCURRENT_STREAMS is interpreted as a global limit and callers of RoundTrip block when needed, waiting for their turn.
SetHTTP2WriteByteTimeout set the http2 WriteByteTimeout, which is the timeout after which the connection will be closed no data can be written to it. The timeout begins when data is available to write, and is extended whenever any bytes are written.
SetIdleConnTimeout set the IdleConnTimeout, which is the maximum amount of time an idle (keep-alive) connection will remain idle before closing itself.
Zero means no limit.
func (t *Transport) SetMaxConnsPerHost(max int) *Transport
SetMaxConnsPerHost set the MaxConnsPerHost, optionally limits the total number of connections per host, including connections in the dialing, active, and idle states. On limit violation, dials will block.
Zero means no limit.
func (t *Transport) SetMaxIdleConns(max int) *Transport
SetMaxIdleConns set the MaxIdleConns, which controls the maximum number of idle (keep-alive) connections across all hosts. Zero means no limit.
func (t *Transport) SetMaxResponseHeaderBytes(max int64) *Transport
SetMaxResponseHeaderBytes set the MaxResponseHeaderBytes, which specifies a limit on how many response bytes are allowed in the server's response header.
Zero means to use a default limit.
SetProxy set the http proxy, only valid for HTTP1 and HTTP2, which specifies a function to return a proxy for a given Request. If the function returns a non-nil error, the request is aborted with the provided error.
The proxy type is determined by the URL scheme. "http", "https", and "socks5" are supported. If the scheme is empty, "http" is assumed.
If Proxy is nil or returns a nil *URL, no proxy is used.
SetProxyConnectHeader set the ProxyConnectHeader, which optionally specifies headers to send to proxies during CONNECT requests. To set the header dynamically, see SetGetProxyConnectHeader.
func (t *Transport) SetReadBufferSize(size int) *Transport
SetReadBufferSize set the ReadBufferSize, which specifies the size of the read buffer used when reading from the transport. If zero, a default (currently 4KB) is used.
SetResponseHeaderTimeout set the ResponseHeaderTimeout, if non-zero, specifies the amount of time to wait for a server's response headers after fully writing the request (including its body, if any). This time does not include the time to read the response body.
SetTLSClientConfig set the custom TLSClientConfig, which specifies the TLS configuration to use with tls.Client. If nil, the default configuration is used. If non-nil, HTTP/2 support may not be enabled by default.
func (*Transport) SetTLSHandshake ¶ added in v3.36.1
SetTLSHandshake set the custom tls handshake function, only valid for HTTP1 and HTTP2, not HTTP3, it specifies an optional dial function for tls handshake, it works even if a proxy is set, can be used to customize the tls fingerprint.
func (*Transport) SetTLSHandshakeTimeout ¶ added in v3.14.0
SetTLSHandshakeTimeout set the TLSHandshakeTimeout, which specifies the maximum amount of time waiting to wait for a TLS handshake.
Zero means no timeout.
func (t *Transport) SetWriteBufferSize(size int) *Transport
SetWriteBufferSize set the WriteBufferSize, which specifies the size of the write buffer used when writing to the transport. If zero, a default (currently 4KB) is used.
func (t *Transport) WrapRoundTrip(wrappers ...HttpRoundTripWrapper) *Transport
WrapRoundTrip adds a transport middleware function that will give the caller an opportunity to wrap the underlying http.RoundTripper.
func (t *Transport) WrapRoundTripFunc(funcs ...HttpRoundTripWrapperFunc) *Transport
WrapRoundTripFunc adds a transport middleware function that will give the caller an opportunity to wrap the underlying http.RoundTripper.
type UploadCallback func(info UploadInfo)
UploadCallback is the callback which will be invoked during multipart upload.
UploadInfo is the information for each UploadCallback call.