httpclient

package
v0.0.43 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2021 License: MIT Imports: 18 Imported by: 3

Documentation

Index

Constants

View Source
const (
	OPT_SSL int = iota
	OPT_PROXY
	PROXY_SOCKS4
	PROXY_SOCKS5
	PROXY_SOCKS4A
	PROXY_HTTP
	PROXY_HTTPS
	OPT_TIMEOUT
)

Variables

This section is empty.

Functions

func GetUrlParam added in v0.0.42

func GetUrlParam(ul, key string) string

GetUrlParam

func HttpBuildQuery

func HttpBuildQuery(values lib.InRow) string

HttpBuildQuery 生成 URL-encode 之后的请求字符串

func UrlEncode added in v0.0.13

func UrlEncode(queryString string) string

UrlEncode url编码

Types

type HttpClient

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

Http 类

func New

func New() *HttpClient

New

func (*HttpClient) Connect

func (h *HttpClient) Connect(url string, values lib.InRow) *HttpResponse

Connect 请求

func (*HttpClient) Delete

func (h *HttpClient) Delete(url string, values lib.InRow) *HttpResponse

Delete 请求

func (*HttpClient) Get

func (h *HttpClient) Get(url string, values lib.InRow) *HttpResponse

Get 请求

func (*HttpClient) Head

func (h *HttpClient) Head(url string) *HttpResponse

Head 请求

func (*HttpClient) Options

func (h *HttpClient) Options(url string, values lib.InRow) *HttpResponse

Options 请求

func (*HttpClient) Patch

func (h *HttpClient) Patch(url string, values lib.InRow) *HttpResponse

Patch 请求

func (*HttpClient) Post

func (h *HttpClient) Post(url string, values lib.InRow) *HttpResponse

Post 请求

func (*HttpClient) PostJson

func (h *HttpClient) PostJson(url string, value interface{}) *HttpResponse

PostJson 请求json

func (*HttpClient) PostMultipart

func (h *HttpClient) PostMultipart(url string, values lib.InRow) *HttpResponse

PostMultipart 请求提交文件

func (*HttpClient) PostXml

func (h *HttpClient) PostXml(url string, value interface{}) *HttpResponse

PostXml 请求xml

func (*HttpClient) Put added in v0.0.33

func (h *HttpClient) Put(url string, values lib.InRow) *HttpResponse

Put 请求

func (*HttpClient) Trace

func (h *HttpClient) Trace(url string, values lib.InRow) *HttpResponse

Trace 请求

func (*HttpClient) WithCookie

func (h *HttpClient) WithCookie(cookies ...*http.Cookie) Httper

WithCookie 自定义cookie

func (*HttpClient) WithHeader

func (h *HttpClient) WithHeader(key string, value interface{}) Httper

WithHeader 自定义头

func (*HttpClient) WithHeaders

func (h *HttpClient) WithHeaders(header lib.InRow) Httper

WithHeaders 自定义头

func (*HttpClient) WithOption

func (h *HttpClient) WithOption(key int, value interface{}) Httper

WithOption 自定义选项

func (*HttpClient) WithOptions

func (h *HttpClient) WithOptions(options lib.IntRow) Httper

WithOption 自定义选项

func (*HttpClient) WithProxy

func (h *HttpClient) WithProxy(proto int, host, port string) Httper

WithProxy 代理

func (*HttpClient) WithRequestBefore added in v0.0.34

func (h *HttpClient) WithRequestBefore(fun RequestBeforeFunc) Httper

WithRequestBefore 请求前调用

func (*HttpClient) WithSSL

func (h *HttpClient) WithSSL(certpemPath, keypemPath, rootcaName string) Httper

WithSSL 设置证书

func (*HttpClient) WithTimeOut

func (h *HttpClient) WithTimeOut(timeout int) Httper

WithTimeOut 超时时间 单位秒

type HttpResponse

type HttpResponse struct {
	Code     int    `json:"code"`
	Err      string `json:"err"`
	BodyByte []byte `json:"bodybyte"`
	Header   http.Header
	Dump     string `json:"dump"`
}

HttpResponse 响应内容

func (*HttpResponse) Body

func (h *HttpResponse) Body() string

Body 内容

func (*HttpResponse) String

func (h *HttpResponse) String() string

String 字符输出

type Httper

type Httper interface {
	WithHeader(key string, value interface{}) Httper
	WithHeaders(header lib.InRow) Httper
	WithOption(key int, value interface{}) Httper
	WithOptions(options lib.IntRow) Httper
	WithCookie(cookies ...*http.Cookie) Httper
	WithSSL(certpemPath, keypemPath, rootcaName string) Httper
	WithProxy(proto int, host, port string) Httper
	WithTimeOut(timeout int) Httper
	Get(url string, values lib.InRow) *HttpResponse
	Put(url string, values lib.InRow) *HttpResponse
	Post(url string, values lib.InRow) *HttpResponse
	PostJson(url string, value interface{}) *HttpResponse
	PostXml(url string, value interface{}) *HttpResponse
	PostMultipart(url string, values lib.InRow) *HttpResponse
	Delete(url string, values lib.InRow) *HttpResponse
	Options(url string, values lib.InRow) *HttpResponse
	Head(url string) *HttpResponse
	Connect(url string, values lib.InRow) *HttpResponse
	Trace(url string, values lib.InRow) *HttpResponse
	Patch(url string, values lib.InRow) *HttpResponse
	WithRequestBefore(fun RequestBeforeFunc) Httper
}

Httper http请求

type RequestBeforeFunc added in v0.0.34

type RequestBeforeFunc func(*http.Request)

RequestBeforeFunc 请求前函数

Jump to

Keyboard shortcuts

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