httpClient

package
v0.3.1 Latest Latest
Warning

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

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

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 (receiver *HttpClient) AddHeaders(headers map[string][]string) *HttpClient

AddHeaders 设置请求头

func (*HttpClient) GenerateRequest

func (receiver *HttpClient) GenerateRequest() *HttpClient

GenerateRequest 生成请求对象

func (*HttpClient) GetRequest

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

GetRequest 获取请求

func (*HttpClient) GetResponse

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

GetResponse 获取响应对象

func (*HttpClient) GetResponseJsonBody

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

GetResponseJsonBody 获取json格式响应体

func (*HttpClient) GetResponseRawBody

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

GetResponseRawBody 获取原始响应体

func (*HttpClient) GetResponseXmlBody

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

GetResponseXmlBody 获取xml格式响应体

func (*HttpClient) SaveResponseSteamFile

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

SaveResponseSteamFile 保存二进制到文件

func (*HttpClient) Send

func (receiver *HttpClient) Send() *HttpClient

Send 发送请求

func (*HttpClient) SetBody

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

SetBody 设置请求体

func (*HttpClient) SetCert added in v0.2.0

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

SetCert 设置SSL证书

func (*HttpClient) SetCssBody

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

SetCssBody 设置Css请求体

func (*HttpClient) SetFormBody

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

SetFormBody 设置表单请求体

func (*HttpClient) SetFormDataBody

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

SetFormDataBody 设置表单数据请求体

func (*HttpClient) SetHeaderAccept

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

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

func (*HttpClient) SetHeaderContentType

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

SetHeaderContentType 设置请求头内容类型

func (*HttpClient) SetHtmlBody

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

SetHtmlBody 设置html请求体

func (*HttpClient) SetJavascriptBody

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

SetJavascriptBody 设置Javascript请求体

func (*HttpClient) SetJsonBody

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

SetJsonBody 设置json请求体

func (*HttpClient) SetMethod

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

SetMethod 设置请求方法

func (*HttpClient) SetPlainBody

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

SetPlainBody 设置纯文本请求体

func (*HttpClient) SetQueries

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

SetQueries 设置请求参数

func (*HttpClient) SetSteamBody

func (receiver *HttpClient) SetSteamBody(file string) *HttpClient

func (*HttpClient) SetUrl

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

SetUrl 设置请求地址

func (*HttpClient) SetXmlBody

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

SetXmlBody 设置xml请求体

type HttpClientContentType

type HttpClientContentType = string

type HttpClientMultiple added in v0.3.0

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

func (*HttpClientMultiple) Add added in v0.3.0

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

Add 添加httpClient对象

func (*HttpClientMultiple) GetClients added in v0.3.0

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

GetClients 获取链接池

func (HttpClientMultiple) New added in v0.3.0

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

func (*HttpClientMultiple) Send added in v0.3.0

func (receiver *HttpClientMultiple) Send() *HttpClientMultiple

Send 批量发送

func (*HttpClientMultiple) SetClients added in v0.3.0

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