Documentation ¶
Index ¶
- Constants
- Variables
- type BasicAuth
- type Request
- func (r *Request) AddCookie(name, value string) *Request
- func (r *Request) AddFile(field, filename string) *Request
- func (r *Request) AddHeader(name, value string) *Request
- func (r *Request) Delete(url string) (*Response, error)
- func (r *Request) Do() (*Response, error)
- func (r *Request) Get(url string) (*Response, error)
- func (r *Request) Head(url string) (*Response, error)
- func (r *Request) Options(url string) (*Response, error)
- func (r *Request) Patch(url string) (*Response, error)
- func (r *Request) Post(url string) (*Response, error)
- func (r *Request) Put(url string) (*Response, error)
- func (r *Request) Reset() *Request
- func (r *Request) SetBasicAuth(name, passwd string) *Request
- func (r *Request) SetBody(body interface{}) *Request
- func (r *Request) SetForm(form interface{}) *Request
- func (r *Request) SetJSON(json interface{}) *Request
- func (r *Request) SetProxyURL(url string) *Request
- func (r *Request) SetQueryString(qs interface{}) *Request
- func (r *Request) SetTokenAuth(token string) *Request
- type Response
- type TokenAuth
- type UploadFile
Constants ¶
View Source
const ( DefaultPayloadContentType = "application/octoc-streams" DefaultJsonContentType = "application/json; charset=utf-8" DefaultFormContentType = "application/x-www-form-urlencoded; charset=utf-8" )
Variables ¶
View Source
var ( DefaultRequestTimeout = 30 * time.Second DefaultDailTimeout = 30 * time.Second DefaultTLSHandshakeTimeout = 30 * time.Second DefaultInsecureSkipVerify = false )
View Source
var DefaultHeaders = map[string]string{ "Connection": "keep-alive", "Accept-Encoding": "gzip, deflate", "Accept": "*/*", "User-Agent": DefaultUserAgent, }
View Source
var DefaultRedirectLimit = 10
DefaultRedirectLimit define max redirect counts
View Source
var DefaultUserAgent = "subchen/go-curl"
View Source
var ErrMaxRedirect = errors.New("Exceeded max redirects")
ErrMaxRedirect when redirect times great than DefaultRedirectLimit will return this error
Functions ¶
This section is empty.
Types ¶
type BasicAuth ¶
func (*BasicAuth) RequestHeaderValue ¶
type Request ¶
type Request struct { Client *http.Client Transport *http.Transport Method string URL string QueryString interface{} // url.Values, map[string]string, map[string][]string Headers map[string]string Cookies map[string]string Body interface{} // io.Reader, string JSON interface{} // any Form interface{} // url.Values, map[string]string, map[string][]string Files []UploadFile Auth interface{} // authorization(BasicAuth, TokenAuth, ...), string ProxyURL string // http(s)://..., sock5://... RedirectDisabled bool }
func NewRequest ¶
func NewRequest() *Request
func (*Request) SetBasicAuth ¶
func (*Request) SetProxyURL ¶
func (*Request) SetQueryString ¶
func (*Request) SetTokenAuth ¶
type Response ¶
Response ...
func (*Response) JSONUnmarshal ¶
JSONUnmarshal unmarshal Response Body
func (*Response) RequestURL ¶
RequestURL return finally request url
type UploadFile ¶
Click to show internal directories.
Click to hide internal directories.