shttp

package
v0.0.0-...-f1241d1 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: MulanPSL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = &http.Client{
	Transport: &http.Transport{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	},
	Timeout: 30 * time.Second,
}
View Source
var DefaultHTTP3Client = &http.Client{
	Transport: &http3.RoundTripper{
		TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
	},
	Timeout: 30 * time.Second,
}

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(http3 bool) *Client

func (*Client) Accept

func (c *Client) Accept(contentTypes string)

Accept sets the Accept header for a request.

func (*Client) Body

func (c *Client) Body(data interface{})

添加请求体

func (*Client) CacheControl

func (c *Client) CacheControl(directive string)

CacheControl sets the client-side Cache-Control directive for a request.

func (*Client) Client

func (c *Client) Client(cl *http.Client)

设置client

func (*Client) ContentType

func (c *Client) ContentType(ct string)

ContentType sets the Content-Type header on a request.

func (*Client) Cookie

func (c *Client) Cookie(name, value string) error

设置Cookie

func (*Client) Delete

func (c *Client) Delete(remoteURL string, data interface{}) error

发送delete请求

func (*Client) GET

func (c *Client) GET(remoteURL string, params map[string]string) error

发送get请求

func (*Client) GetContentLength

func (c *Client) GetContentLength() int64

获取返回的数据大小

func (*Client) GetContentType

func (c *Client) GetContentType() string

获取返回的数据类型

func (*Client) GetResponseData

func (c *Client) GetResponseData(data interface{}) error

接收结果

func (*Client) Head

func (c *Client) Head(remoteURL string, params map[string]string) error

发送head请求

func (*Client) Headers

func (c *Client) Headers(h map[string]string) error

设置头部

func (*Client) POST

func (c *Client) POST(remoteURL string, data interface{}) error

发送post请求

func (*Client) POSTFile

func (c *Client) POSTFile(remoteURL string, otherFields map[string]string, files map[string][]string) error

发送post 文件请求

func (*Client) PUT

func (c *Client) PUT(remoteURL string, data interface{}) error

发送put请求

func (*Client) Params

func (c *Client) Params(params map[string]string)

添加参数

func (*Client) Set

func (c *Client) Set(name, value string)

设置头部

func (*Client) ToFile

func (c *Client) ToFile(filePath string) error

写入文件

func (*Client) ToFileAt

func (c *Client) ToFileAt(filePath string, offset int64) error

写入文件带偏移量

func (*Client) Transport

func (c *Client) Transport(rt http.RoundTripper)

Transport

func (*Client) UserAgent

func (c *Client) UserAgent(s string)

UserAgent sets the User-Agent header.

Jump to

Keyboard shortcuts

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