http_client

package
v7.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: MIT Imports: 15 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRegion              = errors.New("no region from provider")
	ErrNoEndpointsConfigured = errors.New("no endpoints configured")
)

Functions

func DefaultBucketHosts

func DefaultBucketHosts() region.Endpoints

DefaultBucketHosts 默认的 Bucket 域名列表

Types

type BasicHTTPClient

type BasicHTTPClient = clientv2.Client

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client 提供了对七牛 HTTP 客户端

func NewClient

func NewClient(options *Options) *Client

NewClient 用来构建一个新的七牛 HTTP 客户端

func (*Client) Do

func (httpClient *Client) Do(ctx context.Context, request *Request) (*http.Response, error)

Do 发送 HTTP 请求

func (*Client) DoAndAcceptJSON

func (httpClient *Client) DoAndAcceptJSON(ctx context.Context, request *Request, ret interface{}) error

DoAndAcceptJSON 发送 HTTP 请求并接收 JSON 响应

func (*Client) GetBucketQuery

func (httpClient *Client) GetBucketQuery() region.BucketRegionsQuery

func (*Client) GetClient

func (httpClient *Client) GetClient() BasicHTTPClient

func (*Client) GetCredentials

func (httpClient *Client) GetCredentials() credentials.CredentialsProvider

func (*Client) GetHostFreezeDuration

func (httpClient *Client) GetHostFreezeDuration() time.Duration

func (*Client) GetHostRetryConfig

func (httpClient *Client) GetHostRetryConfig() *RetryConfig

func (*Client) GetHostsRetryConfig

func (httpClient *Client) GetHostsRetryConfig() *RetryConfig

func (*Client) GetRegions

func (httpClient *Client) GetRegions() region.RegionsProvider

func (*Client) UseInsecureProtocol

func (httpClient *Client) UseInsecureProtocol() bool

type GetRequestBody

type GetRequestBody = clientv2.GetRequestBody

func GetFormRequestBody

func GetFormRequestBody(info map[string][]string) GetRequestBody

GetFormRequestBody 将数据通过 Form 作为请求 Body 发送

func GetJsonRequestBody

func GetJsonRequestBody(object interface{}) (GetRequestBody, error)

GetJsonRequestBody 将数据通过 JSON 作为请求 Body 发送

func GetMultipartFormRequestBody

func GetMultipartFormRequestBody(info *MultipartForm) GetRequestBody

GetMultipartFormRequestBody 将数据通过 Multipart 表单作为请求 Body 发送

func GetRequestBodyFromReadSeekCloser

func GetRequestBodyFromReadSeekCloser(r compatible_io.ReadSeekCloser) GetRequestBody

GetMultipartFormRequestBody 将二进制数据请求 Body 发送

type Handler

type Handler = clientv2.Handler

type Interceptor

type Interceptor = clientv2.Interceptor

type InterceptorPriority

type InterceptorPriority = clientv2.InterceptorPriority

type MultipartForm

type MultipartForm = clientv2.MultipartForm

MultipartForm 用来构建 Multipart 表单

type MultipartFormBinaryData

type MultipartFormBinaryData struct {
	Data compatible_io.ReadSeekCloser
	Name string
}

type Options

type Options struct {
	BasicHTTPClient     BasicHTTPClient
	BucketQuery         region.BucketRegionsQuery
	Regions             region.RegionsProvider
	Credentials         credentials.CredentialsProvider
	Interceptors        []Interceptor
	UseInsecureProtocol bool
	HostRetryConfig     *RetryConfig
	HostsRetryConfig    *RetryConfig
	HostFreezeDuration  time.Duration
	ShouldFreezeHost    func(req *http.Request, resp *http.Response, err error) bool
}

Options 为构建 Client 提供了可选参数

func (*Options) SetBucketHosts

func (options *Options) SetBucketHosts(bucketHosts region.Endpoints) (err error)

type Request

type Request struct {
	Method         string
	ServiceNames   []region.ServiceName
	Endpoints      region.EndpointsProvider
	Region         region.RegionsProvider
	Path           string
	RawQuery       string
	Query          url.Values
	Header         http.Header
	RequestBody    GetRequestBody
	Credentials    credentials.CredentialsProvider
	AuthType       auth.TokenType
	UpToken        uptoken.UpTokenProvider
	BufferResponse bool
}

Request 包含一个具体的 HTTP 请求的参数

type RetryConfig

type RetryConfig = clientv2.RetryConfig

Jump to

Keyboard shortcuts

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