httpclient

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 19 Imported by: 5

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

func GetUrlParam(ul, key string) string

GetUrlParam

func HttpBuildQuery

func HttpBuildQuery(values lib.InRow) string

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

func SaveRemoteFile

func SaveRemoteFile(remoteFile, localFullName string) bool

保存远程文件到本地 remoteFile远程文件地址 localFullName本地文件地址

func UrlDecode

func UrlDecode(queryString string) string

UrlDecode url解码

func UrlEncode

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

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

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

type RequestBeforeFunc func(*http.Request)

RequestBeforeFunc 请求前函数

Jump to

Keyboard shortcuts

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