Documentation ¶
Index ¶
- Constants
- Variables
- type DownloadCallback
- type GoNet
- type GoURL
- func (this *GoURL) AbsoluteURL(rel, base string) (string, error)
- func (this *GoURL) Clean(uri string) string
- func (this *GoURL) HasPrefix(url string) bool
- func (this *GoURL) IsDomainName(s string) bool
- func (this *GoURL) Join(str ...string) string
- func (this *GoURL) RemoveHTTPPrefix(url string) string
- type LogFunc
- type LogLevel
- type Request
- func (this *Request) AddHeader(key, value string) *Request
- func (this *Request) Bytes() ([]byte, error)
- func (this *Request) Debug(debug bool) *Request
- func (this *Request) DisableCookie() *Request
- func (this *Request) DisableDebug() *Request
- func (this *Request) DisableInsecureTLSSkipVerify() *Request
- func (this *Request) Dump() []byte
- func (this *Request) EnableCookie() *Request
- func (this *Request) EnableDebug() *Request
- func (this *Request) EnableInsecureTLSSkipVerify() *Request
- func (this *Request) Error() error
- func (this *Request) Fetch(method, rawurl string, requestData io.Reader, hdr http.Header, ...) error
- func (this *Request) GET(URL string) *Request
- func (this *Request) JSON(v interface{}) error
- func (this *Request) Logf(logf LogFunc) *Request
- func (this *Request) OnDownload(f DownloadCallback)
- func (this *Request) OnRequest(f RequestCallback)
- func (this *Request) POST(URL string, requestData map[string]string) *Request
- func (this *Request) POSTMultipart(URL string, requestData map[string][]byte) *Request
- func (this *Request) POSTRaw(URL string, requestData []byte) *Request
- func (this *Request) Response() *http.Response
- func (this *Request) Save(fileName string) error
- func (this *Request) SendJSON(URL string, requestData map[string]string) *Request
- func (this *Request) SetCharacterEncoding(characterEncoding string) *Request
- func (this *Request) SetClient(client *http.Client) *Request
- func (this *Request) SetConnectTimeout(connectTimeout time.Duration) *Request
- func (this *Request) SetContentType(contentType string) *Request
- func (this *Request) SetContext(ctx context.Context) *Request
- func (this *Request) SetCookie(cookie *http.Cookie) *Request
- func (this *Request) SetHeader(headers http.Header) *Request
- func (this *Request) SetInsecureTLSSkipVerify(skip bool) *Request
- func (this *Request) SetProxy(proxyURL *url.URL) *Request
- func (this *Request) SetProxyFunc(proxy func(*http.Request) (*url.URL, error)) *Request
- func (this *Request) SetProxyURL(proxyURL string) *Request
- func (this *Request) SetReadWriteTimeout(readWriteTimeout time.Duration) *Request
- func (this *Request) SetRetries(retries int) *Request
- func (this *Request) SetTimeout(timeout time.Duration) *Request
- func (this *Request) SetUserAgent(userAgent string) *Request
- func (this *Request) String() (string, error)
- func (this *Request) UseCookie(use bool) *Request
- func (this *Request) XML(v interface{}) error
- type RequestCallback
Constants ¶
Variables ¶
var DefaultUserAgent string = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.90 Safari/537.36"
var DefaultUserAgent string = "abcdefghijklmnopqrstuvwxyz"
var HTTPRequestHelper = NewRequest()
var NetHelper = &GoNet{}
var URLHelper = &GoURL{}
Functions ¶
This section is empty.
Types ¶
type DownloadCallback ¶
DownloadCallback is a type alias for OnDownload callback functions
type GoNet ¶
type GoNet struct{}
func (*GoNet) Ping ¶
Ping connects to the address on the named network, using net.DialTimeout, and immediately closes it. It returns the connection error. A nil value means success. For examples of valid values of network and address, see the documentation of net.Dial err := Ping("tcp", "0.0.0.0:8088", time.Second)
type GoURL ¶
type GoURL struct{}
func (*GoURL) AbsoluteURL ¶
相对路径转绝对路径
func (*GoURL) IsDomainName ¶
isDomainName checks if a string is a presentation-format domain name (currently restricted to hostname-compatible "preferred name" LDH labels and SRV-like "underscore labels"; see golang.org/issue/12421).
func (*GoURL) RemoveHTTPPrefix ¶
移除 URL 的 HTTP 或 HTTPS 前缀
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func (*Request) DisableCookie ¶
func (*Request) DisableDebug ¶
func (*Request) DisableInsecureTLSSkipVerify ¶
func (*Request) EnableInsecureTLSSkipVerify ¶
func (*Request) OnDownload ¶
func (this *Request) OnDownload(f DownloadCallback)
func (*Request) OnRequest ¶
func (this *Request) OnRequest(f RequestCallback)
OnRequest registers a function. Function will be executed on every request made by the Collector
func (*Request) POST ¶
req.POST("http://example.com/login", map[string]string{"username": "admin", "password": "admin"})
func (*Request) POSTMultipart ¶
return map[string][]byte{ "firstname": []byte("one"), "lastname": []byte("two"), "email": []byte("onetwo@example.com"), "file": imgData, } }
req.POSTMultipart("http://localhost:8080/", generateFormData())
func (*Request) POSTRaw ¶
payload := []byte(`{"user":{"email":"anon@example.com","password":"mypassword"}}`) req.POSTRaw("http://example.com/login", payload)
func (*Request) SetCharacterEncoding ¶
func (*Request) SetConnectTimeout ¶
func (*Request) SetContentType ¶
func (*Request) SetInsecureTLSSkipVerify ¶
func (*Request) SetProxyFunc ¶
func (*Request) SetReadWriteTimeout ¶
func (*Request) SetRetries ¶
func (*Request) SetUserAgent ¶
type RequestCallback ¶
RequestCallback is a type alias for OnRequest callback functions