Documentation ¶
Index ¶
- Variables
- func BatchFileUpload2Internal(files []FileUpload) []grequests.FileUpload
- func CookieStr2Cookie(cookieStr string) []*http.Cookie
- type FileUpload
- type HTTPClient
- func (api *HTTPClient) CronClearIdle(task *routine.Task, interval time.Duration) error
- func (api *HTTPClient) Delete(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (api *HTTPClient) Get(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (api *HTTPClient) Head(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (api *HTTPClient) Method(method string, url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (api *HTTPClient) Options(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (api *HTTPClient) Patch(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (api *HTTPClient) Post(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (api *HTTPClient) Put(url string, rOpts ...ROpt) (*HTTPResponse, error)
- type HTTPRequest
- type HTTPResponse
- func Delete(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func Get(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func Head(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func NewResponse(response *grequests.Response) *HTTPResponse
- func Options(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func Patch(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func Post(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func Put(url string, rOpts ...ROpt) (*HTTPResponse, error)
- func (resp *HTTPResponse) Bytes() []byte
- func (resp *HTTPResponse) ContentType() string
- func (resp *HTTPResponse) Cookie(name string) (*http.Cookie, error)
- func (resp *HTTPResponse) Cookies() []*http.Cookie
- func (resp *HTTPResponse) Error() error
- func (resp *HTTPResponse) FileName() (string, error)
- func (resp *HTTPResponse) FileNameWithCustom(nameField string) (string, error)
- func (resp *HTTPResponse) Header(name string) string
- func (resp *HTTPResponse) Headers(name string) []string
- func (resp *HTTPResponse) Json(dst interface{}) error
- func (resp *HTTPResponse) OK() bool
- func (resp *HTTPResponse) Status() int
- func (resp *HTTPResponse) Text() string
- type ROpt
- func RWithCookie(cookie []*http.Cookie) ROpt
- func RWithFile(file FileUpload) ROpt
- func RWithFiles(files []FileUpload) ROpt
- func RWithForm(form map[string]string) ROpt
- func RWithHeader(header map[string]string) ROpt
- func RWithJson(body []byte) ROpt
- func RWithParams(params map[string]string) ROpt
- func RWithTimeout(timeout time.Duration) ROpt
- func RWithUserAgent(userAgent string) ROpt
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func BatchFileUpload2Internal ¶
func BatchFileUpload2Internal(files []FileUpload) []grequests.FileUpload
BatchFileUpload2Internal 批量转化
func CookieStr2Cookie ¶
Types ¶
type FileUpload ¶
type FileUpload struct { FileName string //文件名 FileContents io.ReadCloser //文件流 FieldName string //上传文件表单 文件字段 FileMime string //文件类型, 默认是application/octet-stream }
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
func NewHTTPClient ¶
func NewHTTPClient(req *HTTPRequest) *HTTPClient
func (*HTTPClient) CronClearIdle ¶
CronClearIdle 定时清理闲置连接
func (*HTTPClient) Delete ¶
func (api *HTTPClient) Delete(url string, rOpts ...ROpt) (*HTTPResponse, error)
Delete DELETE请求方法
func (*HTTPClient) Get ¶
func (api *HTTPClient) Get(url string, rOpts ...ROpt) (*HTTPResponse, error)
Get GET请求方法
func (*HTTPClient) Head ¶
func (api *HTTPClient) Head(url string, rOpts ...ROpt) (*HTTPResponse, error)
Head HEAD请求方法
func (*HTTPClient) Method ¶
func (api *HTTPClient) Method(method string, url string, rOpts ...ROpt) (*HTTPResponse, error)
Method 请求
func (*HTTPClient) Options ¶
func (api *HTTPClient) Options(url string, rOpts ...ROpt) (*HTTPResponse, error)
Options OPTIONS请求方法
func (*HTTPClient) Patch ¶
func (api *HTTPClient) Patch(url string, rOpts ...ROpt) (*HTTPResponse, error)
Patch PATCH请求方法
func (*HTTPClient) Post ¶
func (api *HTTPClient) Post(url string, rOpts ...ROpt) (*HTTPResponse, error)
Post Post请求方法
func (*HTTPClient) Put ¶
func (api *HTTPClient) Put(url string, rOpts ...ROpt) (*HTTPResponse, error)
Put PUT请求方法
type HTTPRequest ¶
type HTTPRequest struct { Url string //Url Header map[string]string //请求头 Params map[string]string //查询字符串 Form map[string]string //表单参数 Json []byte //json请求体 Cookie []*http.Cookie //Cookie UserAgent string //UserAgent Timeout time.Duration //请求超时时间 Files []FileUpload //文件 }
func NewRequest ¶
func NewRequest(args ...ROpt) *HTTPRequest
type HTTPResponse ¶
type HTTPResponse struct {
// contains filtered or unexported fields
}
func NewResponse ¶
func NewResponse(response *grequests.Response) *HTTPResponse
func (*HTTPResponse) Bytes ¶
func (resp *HTTPResponse) Bytes() []byte
Bytes 字节, 适用于小文件, 大文件推荐使用Stream
func (*HTTPResponse) ContentType ¶
func (resp *HTTPResponse) ContentType() string
ContentType 获取Content-Type
func (*HTTPResponse) Cookie ¶
func (resp *HTTPResponse) Cookie(name string) (*http.Cookie, error)
Cookie 获取Cookie, 没有返回空字符串
func (*HTTPResponse) Cookies ¶
func (resp *HTTPResponse) Cookies() []*http.Cookie
Cookies 获取Cookies, 没有返回空切片
func (*HTTPResponse) FileNameWithCustom ¶
func (resp *HTTPResponse) FileNameWithCustom(nameField string) (string, error)
FileNameWithCustom 文件名
func (*HTTPResponse) Headers ¶
func (resp *HTTPResponse) Headers(name string) []string
Headers 返回的Header, 大小写不敏感
type ROpt ¶
type ROpt func(r *HTTPRequest)
func RWithCookie ¶
func RWithFile ¶
func RWithFile(file FileUpload) ROpt
func RWithFiles ¶
func RWithFiles(files []FileUpload) ROpt
func RWithHeader ¶
func RWithParams ¶
func RWithTimeout ¶
func RWithUserAgent ¶
Click to show internal directories.
Click to hide internal directories.