client

package
v7.21.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: MIT Imports: 19 Imported by: 12

Documentation

Index

Constants

View Source
const (
	RequestHeaderKeyXQiniuDate = "X-Qiniu-Date"
)

Variables

View Source
var (
	UserAgent     = getUserAgentWithAppName("default")
	DefaultClient = Client{&http.Client{Transport: DefaultTransport}}

	// 用来打印调试信息
	DebugMode     = false
	DeepDebugInfo = false
)
View Source
var DefaultTransport http.RoundTripper = &http.Transport{
	Proxy:                 http.ProxyFromEnvironment,
	DialContext:           defaultDialFunc,
	MaxIdleConns:          100,
	IdleConnTimeout:       90 * time.Second,
	TLSHandshakeTimeout:   10 * time.Second,
	ExpectContinueTimeout: 1 * time.Second,
}

Functions

func AddHttpHeaderRange added in v7.18.0

func AddHttpHeaderRange(header http.Header, contentRange string)

func CallRet

func CallRet(ctx context.Context, ret interface{}, resp *http.Response) (err error)

func DecodeJsonFromReader added in v7.17.0

func DecodeJsonFromReader(reader io.Reader, v interface{}) error

func ResponseError

func ResponseError(resp *http.Response) error

func SetAppName

func SetAppName(userApp string) error

userApp should be [A-Za-z0-9_\ \-\.]*

func TurnOnDebug

func TurnOnDebug()

TurnOnDebug 开启Debug模式

func WithDialTimeout added in v7.21.0

func WithDialTimeout(ctx context.Context, timeout time.Duration) context.Context

func WithKeepAliveInterval added in v7.21.0

func WithKeepAliveInterval(ctx context.Context, interval time.Duration) context.Context

func WithResolvedIPs added in v7.21.0

func WithResolvedIPs(ctx context.Context, domain string, ips []net.IP) context.Context

Types

type Client

type Client struct {
	*http.Client
}

Client 负责发送HTTP请求到七牛接口服务器

func (Client) Call

func (r Client) Call(ctx context.Context, ret interface{}, method, reqUrl string, headers http.Header) (err error)

func (Client) CallWith

func (r Client) CallWith(ctx context.Context, ret interface{}, method, reqUrl string, headers http.Header, body io.Reader,
	bodyLength int) (err error)

func (Client) CallWith64

func (r Client) CallWith64(ctx context.Context, ret interface{}, method, reqUrl string, headers http.Header, body io.Reader,
	bodyLength int64) (err error)

func (Client) CallWithBodyGetter added in v7.9.7

func (r Client) CallWithBodyGetter(ctx context.Context, ret interface{}, method, reqUrl string, headers http.Header, body io.Reader,
	getBody func() (io.ReadCloser, error), bodyLength int64) (err error)

func (Client) CallWithForm

func (r Client) CallWithForm(ctx context.Context, ret interface{}, method, reqUrl string, headers http.Header,
	param map[string][]string) (err error)

func (Client) CallWithJson

func (r Client) CallWithJson(ctx context.Context, ret interface{}, method, reqUrl string, headers http.Header,
	param interface{}) (err error)

func (Client) CredentialedCall

func (r Client) CredentialedCall(ctx context.Context, cred *auth.Credentials, tokenType auth.TokenType, ret interface{},
	method, reqUrl string, headers http.Header) error

func (Client) CredentialedCallWith

func (r Client) CredentialedCallWith(ctx context.Context, cred *auth.Credentials, tokenType auth.TokenType, ret interface{},
	method, reqUrl string, headers http.Header, body io.Reader, bodyLength int) error

func (Client) CredentialedCallWith64

func (r Client) CredentialedCallWith64(ctx context.Context, cred *auth.Credentials, tokenType auth.TokenType, ret interface{},
	method, reqUrl string, headers http.Header, body io.Reader, bodyLength int64) error

func (Client) CredentialedCallWithForm

func (r Client) CredentialedCallWithForm(ctx context.Context, cred *auth.Credentials, tokenType auth.TokenType, ret interface{},
	method, reqUrl string, headers http.Header, param map[string][]string) error

func (Client) CredentialedCallWithJson

func (r Client) CredentialedCallWithJson(ctx context.Context, cred *auth.Credentials, tokenType auth.TokenType, ret interface{},
	method, reqUrl string, headers http.Header, param interface{}) error

func (Client) Do

func (r Client) Do(ctx context.Context, req *http.Request) (resp *http.Response, err error)

func (Client) DoRequest

func (r Client) DoRequest(ctx context.Context, method, reqUrl string, headers http.Header) (resp *http.Response, err error)

func (Client) DoRequestWith

func (r Client) DoRequestWith(ctx context.Context, method, reqUrl string, headers http.Header, body io.Reader,
	bodyLength int) (resp *http.Response, err error)

func (Client) DoRequestWith64

func (r Client) DoRequestWith64(ctx context.Context, method, reqUrl string, headers http.Header, body io.Reader,
	bodyLength int64) (resp *http.Response, err error)

func (Client) DoRequestWithBodyGetter added in v7.9.7

func (r Client) DoRequestWithBodyGetter(ctx context.Context, method, reqUrl string, headers http.Header, body io.Reader,
	getBody func() (io.ReadCloser, error), bodyLength int64) (resp *http.Response, err error)

func (Client) DoRequestWithForm

func (r Client) DoRequestWithForm(ctx context.Context, method, reqUrl string, headers http.Header,
	data map[string][]string) (resp *http.Response, err error)

func (Client) DoRequestWithJson

func (r Client) DoRequestWithJson(ctx context.Context, method, reqUrl string, headers http.Header,
	data interface{}) (resp *http.Response, err error)

type ErrorInfo

type ErrorInfo struct {
	Err       string `json:"error,omitempty"`
	ErrorCode string `json:"error_code,omitempty"`
	Key       string `json:"key,omitempty"`
	Reqid     string `json:"reqid,omitempty"`
	Errno     int    `json:"errno,omitempty"`
	Code      int    `json:"code"`
}

func (*ErrorInfo) Error

func (r *ErrorInfo) Error() string

func (*ErrorInfo) ErrorDetail

func (r *ErrorInfo) ErrorDetail() string

func (*ErrorInfo) HttpCode

func (r *ErrorInfo) HttpCode() int

func (*ErrorInfo) RpcError

func (r *ErrorInfo) RpcError() (code, errno int, key, err string)

Jump to

Keyboard shortcuts

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