httpClient

package
v2.19.15 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContentTypeJson       HttpClientContentType = "json"
	ContentTypeXml        HttpClientContentType = "xml"
	ContentTypeForm       HttpClientContentType = "form"
	ContentTypeFormData   HttpClientContentType = "form-data"
	ContentTypePlain      HttpClientContentType = "plain"
	ContentTypeHtml       HttpClientContentType = "html"
	ContentTypeCss        HttpClientContentType = "css"
	ContentTypeJavascript HttpClientContentType = "javascript"
	ContentTypeSteam      HttpClientContentType = "steam"

	AcceptJson       httpClientAccept = "json"
	AcceptXml        httpClientAccept = "xml"
	AcceptPlain      httpClientAccept = "plain"
	AcceptHtml       httpClientAccept = "html"
	AcceptCss        httpClientAccept = "css"
	AcceptJavascript httpClientAccept = "javascript"
	AcceptSteam      httpClientAccept = "steam"
	AcceptAny        httpClientAccept = "any"
)

Functions

This section is empty.

Types

type Accept

type Accept struct {
	ContentTypeStruct
}

func (Accept) GetValue

func (Accept) GetValue(key string) string

GetValue http客户端接受内容类型

type ContentType

type ContentType struct {
	ContentTypeStruct
}

ContentType http客户端内容类型

func (ContentType) GetValue

func (ContentType) GetValue(key string) string

GetValue http客户端请求内容类型

type ContentTypeStruct

type ContentTypeStruct struct {
	Key   string
	Value string
}

type HttpClient

type HttpClient struct {
	Err error
	// contains filtered or unexported fields
}

HttpClient http客户端

func New

func New(url string) *HttpClient

New 实例化:http客户端

func NewDelete

func NewDelete(url string) *HttpClient

NewDelete 实例化:http客户端delete请求

func NewGet

func NewGet(url string) *HttpClient

NewGet 实例化:http客户端get请求

func NewPost

func NewPost(url string) *HttpClient

NewPost 实例化:http客户端post请求

func NewPut

func NewPut(url string) *HttpClient

NewPut 实例化:http客户端put请求

func (*HttpClient) AddHeaders

func (r *HttpClient) AddHeaders(headers map[string][]string) *HttpClient

AddHeaders 设置请求头

func (*HttpClient) GenerateRequest

func (r *HttpClient) GenerateRequest() *HttpClient

GenerateRequest 生成请求对象

func (*HttpClient) GetRequest

func (r *HttpClient) GetRequest() *http.Request

GetRequest 获取请求

func (*HttpClient) GetResponse

func (r *HttpClient) GetResponse() *http.Response

GetResponse 获取响应对象

func (*HttpClient) GetResponseJsonBody

func (r *HttpClient) GetResponseJsonBody(target any) *HttpClient

GetResponseJsonBody 获取json格式响应体

func (*HttpClient) GetResponseRawBody

func (r *HttpClient) GetResponseRawBody() []byte

GetResponseRawBody 获取原始响应体

func (*HttpClient) GetResponseXmlBody

func (r *HttpClient) GetResponseXmlBody(target any) *HttpClient

GetResponseXmlBody 获取xml格式响应体

func (*HttpClient) ParseByContentType

func (r *HttpClient) ParseByContentType(target any) *HttpClient

ParseByContentType 根据响应头Content-Type自动解析响应体

func (*HttpClient) SaveResponseSteamFile

func (r *HttpClient) SaveResponseSteamFile(filename string) *HttpClient

SaveResponseSteamFile 保存二进制到文件

func (*HttpClient) Send

func (r *HttpClient) Send() *HttpClient

Send 发送请求

func (*HttpClient) SetAuthorization

func (r *HttpClient) SetAuthorization(username, password, title string) *HttpClient

SetAuthorization 设置认证

func (*HttpClient) SetBody

func (r *HttpClient) SetBody(body []byte) *HttpClient

SetBody 设置请求体

func (*HttpClient) SetCert

func (r *HttpClient) SetCert(filename string) *HttpClient

SetCert 设置SSL证书

func (*HttpClient) SetCssBody

func (r *HttpClient) SetCssBody(text string) *HttpClient

SetCssBody 设置Css请求体

func (*HttpClient) SetFormBody

func (r *HttpClient) SetFormBody(body map[string]string) *HttpClient

SetFormBody 设置表单请求体

func (*HttpClient) SetFormDataBody

func (r *HttpClient) SetFormDataBody(texts map[string]string, files map[string]string) *HttpClient

SetFormDataBody 设置表单数据请求体

func (*HttpClient) SetHeaderAccept

func (r *HttpClient) SetHeaderAccept(key string) *HttpClient

SetHeaderAccept 设置请求头接受内容类型

func (*HttpClient) SetHeaderContentType

func (r *HttpClient) SetHeaderContentType(key string) *HttpClient

SetHeaderContentType 设置请求头内容类型

func (*HttpClient) SetHtmlBody

func (r *HttpClient) SetHtmlBody(text string) *HttpClient

SetHtmlBody 设置html请求体

func (*HttpClient) SetJavascriptBody

func (r *HttpClient) SetJavascriptBody(text string) *HttpClient

SetJavascriptBody 设置Javascript请求体

func (*HttpClient) SetJsonBody

func (r *HttpClient) SetJsonBody(body any) *HttpClient

SetJsonBody 设置json请求体

func (*HttpClient) SetMethod

func (r *HttpClient) SetMethod(method string) *HttpClient

SetMethod 设置请求方法

func (*HttpClient) SetPlainBody

func (r *HttpClient) SetPlainBody(text string) *HttpClient

SetPlainBody 设置纯文本请求体

func (*HttpClient) SetQueries

func (r *HttpClient) SetQueries(queries map[string]string) *HttpClient

SetQueries 设置请求参数

func (*HttpClient) SetSteamBody

func (r *HttpClient) SetSteamBody(filename string) *HttpClient

SetSteamBody 设置二进制文件

func (*HttpClient) SetTimeoutSecond

func (r *HttpClient) SetTimeoutSecond(timeoutSecond int64) *HttpClient

SetTimeoutSecond 设置超时

func (*HttpClient) SetUrl

func (r *HttpClient) SetUrl(url string) *HttpClient

SetUrl 设置请求地址

func (*HttpClient) SetXmlBody

func (r *HttpClient) SetXmlBody(body any) *HttpClient

SetXmlBody 设置xml请求体

type HttpClientContentType

type HttpClientContentType = string

type HttpClientMultiple

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

func (*HttpClientMultiple) Add

func (receiver *HttpClientMultiple) Add(hc *HttpClient) *HttpClientMultiple

Add 添加httpClient对象

func (*HttpClientMultiple) GetClients

func (receiver *HttpClientMultiple) GetClients() []*HttpClient

GetClients 获取链接池

func (HttpClientMultiple) New

New New 实例化:批量请求对象

func (*HttpClientMultiple) Send

func (receiver *HttpClientMultiple) Send() *HttpClientMultiple

Send 批量发送

func (*HttpClientMultiple) SetClients

func (receiver *HttpClientMultiple) SetClients(clients []*HttpClient) *HttpClientMultiple

SetClients 设置httpClient对象

Jump to

Keyboard shortcuts

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