import "code.gitea.io/gitea/modules/httplib"
SetDefaultSetting overwrites default settings
func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error)
TimeoutDialer returns functions of connection dialer with timeout settings for http.Transport Dial field.
type Request struct {
// contains filtered or unexported fields
}
Request provides more useful methods for requesting one url than http.Request.
Delete returns *Request DELETE method.
Get returns *Request with GET method.
Head returns *Request with HEAD method.
NewRequest returns *Request with specific method
Post returns *Request with POST method.
Put returns *Request with PUT method.
Body adds request raw body. it supports string and []byte.
Bytes returns the body []byte in response. it calls Response inner.
Debug sets show debug or not when executing request.
Header add header item string in request.
HeaderWithSensitiveCase add header item in request and keep the case of the header key.
Headers returns headers in request.
Param adds query param in to request. params build query string as ?key1=value1&key2=value2...
PostFile uploads file via http
Response executes request client gets response manually.
SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.
SetCookie add cookie into request.
SetEnableCookie sets enable/disable cookiejar
SetProtocolVersion sets the protocol version for incoming requests. Client requests always use HTTP/1.1.
SetProxy sets http proxy example:
func(req *http.Request) (*url.URL, error) { u, _ := url.ParseRequestURI("http://127.0.0.1:8118") return u, nil }
SetTLSClientConfig sets tls connection configurations if visiting https url.
SetTimeout sets connect time out and read-write time out for BeegoRequest.
func (r *Request) SetTransport(transport http.RoundTripper) *Request
SetTransport sets transport to
SetUserAgent sets User-Agent header field
Setting changes request settings
String returns the body string in response. it calls Response inner.
ToFile saves the body data in response to one file. it calls Response inner.
ToJSON returns the map that marshals from the body bytes as json in response . it calls Response inner.
ToXML returns the map that marshals from the body bytes as xml in response . it calls Response inner.
type Settings struct { ShowDebug bool UserAgent string ConnectTimeout time.Duration ReadWriteTimeout time.Duration TLSClientConfig *tls.Config Proxy func(*http.Request) (*url.URL, error) Transport http.RoundTripper EnableCookie bool }
Settings is the default settings for http client
Package httplib imports 17 packages (graph) and is imported by 43 packages. Updated 2019-10-02. Refresh now. Tools for package owners.