gitea: code.gitea.io/gitea/modules/httplib Index | Files

package httplib

import "code.gitea.io/gitea/modules/httplib"

Index

Package Files

httplib.go

func SetDefaultSetting Uses

func SetDefaultSetting(setting Settings)

SetDefaultSetting overwrites default settings

func TimeoutDialer Uses

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 Uses

type Request struct {
    // contains filtered or unexported fields
}

Request provides more useful methods for requesting one url than http.Request.

func Delete Uses

func Delete(url string) *Request

Delete returns *Request DELETE method.

func Get Uses

func Get(url string) *Request

Get returns *Request with GET method.

func Head(url string) *Request

Head returns *Request with HEAD method.

func NewRequest Uses

func NewRequest(url, method string) *Request

NewRequest returns *Request with specific method

func Post Uses

func Post(url string) *Request

Post returns *Request with POST method.

func Put Uses

func Put(url string) *Request

Put returns *Request with PUT method.

func (*Request) Body Uses

func (r *Request) Body(data interface{}) *Request

Body adds request raw body. it supports string and []byte.

func (*Request) Bytes Uses

func (r *Request) Bytes() ([]byte, error)

Bytes returns the body []byte in response. it calls Response inner.

func (*Request) Debug Uses

func (r *Request) Debug(isdebug bool) *Request

Debug sets show debug or not when executing request.

func (*Request) Header Uses

func (r *Request) Header(key, value string) *Request

Header add header item string in request.

func (*Request) HeaderWithSensitiveCase Uses

func (r *Request) HeaderWithSensitiveCase(key, value string) *Request

HeaderWithSensitiveCase add header item in request and keep the case of the header key.

func (*Request) Headers Uses

func (r *Request) Headers() http.Header

Headers returns headers in request.

func (*Request) Param Uses

func (r *Request) Param(key, value string) *Request

Param adds query param in to request. params build query string as ?key1=value1&key2=value2...

func (*Request) PostFile Uses

func (r *Request) PostFile(formname, filename string) *Request

PostFile uploads file via http

func (*Request) Response Uses

func (r *Request) Response() (*http.Response, error)

Response executes request client gets response manually.

func (*Request) SetBasicAuth Uses

func (r *Request) SetBasicAuth(username, password string) *Request

SetBasicAuth sets the request's Authorization header to use HTTP Basic Authentication with the provided username and password.

func (*Request) SetCookie Uses

func (r *Request) SetCookie(cookie *http.Cookie) *Request

SetCookie add cookie into request.

func (*Request) SetEnableCookie Uses

func (r *Request) SetEnableCookie(enable bool) *Request

SetEnableCookie sets enable/disable cookiejar

func (*Request) SetProtocolVersion Uses

func (r *Request) SetProtocolVersion(vers string) *Request

SetProtocolVersion sets the protocol version for incoming requests. Client requests always use HTTP/1.1.

func (*Request) SetProxy Uses

func (r *Request) SetProxy(proxy func(*http.Request) (*url.URL, error)) *Request

SetProxy sets http proxy example:

func(req *http.Request) (*url.URL, error) {
	u, _ := url.ParseRequestURI("http://127.0.0.1:8118")
	return u, nil
}

func (*Request) SetTLSClientConfig Uses

func (r *Request) SetTLSClientConfig(config *tls.Config) *Request

SetTLSClientConfig sets tls connection configurations if visiting https url.

func (*Request) SetTimeout Uses

func (r *Request) SetTimeout(connectTimeout, readWriteTimeout time.Duration) *Request

SetTimeout sets connect time out and read-write time out for BeegoRequest.

func (*Request) SetTransport Uses

func (r *Request) SetTransport(transport http.RoundTripper) *Request

SetTransport sets transport to

func (*Request) SetUserAgent Uses

func (r *Request) SetUserAgent(useragent string) *Request

SetUserAgent sets User-Agent header field

func (*Request) Setting Uses

func (r *Request) Setting(setting Settings) *Request

Setting changes request settings

func (*Request) String Uses

func (r *Request) String() (string, error)

String returns the body string in response. it calls Response inner.

func (*Request) ToFile Uses

func (r *Request) ToFile(filename string) error

ToFile saves the body data in response to one file. it calls Response inner.

func (*Request) ToJSON Uses

func (r *Request) ToJSON(v interface{}) error

ToJSON returns the map that marshals from the body bytes as json in response . it calls Response inner.

func (*Request) ToXML Uses

func (r *Request) ToXML(v interface{}) error

ToXML returns the map that marshals from the body bytes as xml in response . it calls Response inner.

type Settings Uses

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 11 packages. Updated 2019-07-16. Refresh now. Tools for package owners.