v1.0.11 Latest Latest

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 13 Imported by: 0




View Source
const (
	UserAgent      = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36"
	Accept         = "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
	AcceptEncoding = "gzip,deflate"
	AcceptLanguage = "zh-cn"
	AcceptCharset  = "gb2312,utf-8;q=0.7,*;q=0.7"
	Timeout        = 30

	ContentType_xml      = "application/xml"
	ContentType_json     = "application/json"
	ContentType_multipar = "multipart/form-data"
	ContentType_form     = "application/x-www-form-urlencoded"

	Method_GET    = "GET"
	Method_POST   = "POST"
	Method_PUT    = "PUT"
	Method_PATCH  = "PATCH"


This section is empty.


This section is empty.


type HttpUtil

type HttpUtil struct {
	UserAgent      string
	Accept         string
	AcceptEncoding string
	AcceptLanguage string
	AcceptCharset  string
	Timeout        time.Duration
	Headers        map[string]string
	UseCookie      bool
	CookieJar      *cookiejar.Jar

func NewDefaultHttpUtil

func NewDefaultHttpUtil() HttpUtil

func NewHttpUtil

func NewHttpUtil(UserAgent, Accept, AcceptEncoding, AcceptLanguage, AcceptCharset string, Timeout time.Duration) HttpUtil

func (*HttpUtil) DownFile

func (hUtil *HttpUtil) DownFile(urlStr string, _reqParm ...ReqParm) ([]byte, string)

func (*HttpUtil) Get

func (hUtil *HttpUtil) Get(urlStr string, _reqParm ...ReqParm) string

func (*HttpUtil) GetBytes

func (hUtil *HttpUtil) GetBytes(urlStr string, reqParm ...ReqParm) []byte

func (*HttpUtil) GetTransport

func (hUtil *HttpUtil) GetTransport() *http.Transport

func (*HttpUtil) Head

func (hUtil *HttpUtil) Head(urlStr string, postData []byte, _reqParm ...ReqParm) http.Header

func (*HttpUtil) InitCookie

func (hUtil *HttpUtil) InitCookie()

func (*HttpUtil) Post

func (hUtil *HttpUtil) Post(urlStr string, postData url.Values, _reqParm ...ReqParm) string

func (*HttpUtil) PostMap added in v1.0.8

func (hUtil *HttpUtil) PostMap(urlStr string, postDataMap map[string]string, _reqParm ...ReqParm) string

func (*HttpUtil) Req

func (hUtil *HttpUtil) Req(method string, urlStr string, postData []byte, _reqParm ...ReqParm) []byte

func (*HttpUtil) TimeoutDialer

func (hUtil *HttpUtil) TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)

type ReqParm

type ReqParm struct {
	UserAgent string
	Referer   string
	MediaType string
	Charset   string

Jump to

Keyboard shortcuts

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