httplib

package
v0.9.128 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2017 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetDefaultSetting added in v0.5.0

func SetDefaultSetting(setting Settings)

Overwrite default settings

func TimeoutDialer

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.

Types

type Request added in v0.6.9

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

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

func Delete

func Delete(url string) *Request

Delete returns *Request DELETE method.

func Get

func Get(url string) *Request

Get returns *Request with GET method.

func Head(url string) *Request

Head returns *Request with HEAD method.

func Post

func Post(url string) *Request

Post returns *Request with POST method.

func Put

func Put(url string) *Request

Put returns *Request with PUT method.

func (*Request) Body added in v0.6.9

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

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

func (*Request) Bytes added in v0.6.9

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

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

func (*Request) Debug added in v0.6.9

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

Debug sets show debug or not when executing request.

func (*Request) Header added in v0.6.9

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

Header add header item string in request.

func (*Request) Headers added in v0.6.9

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

func (*Request) Param added in v0.6.9

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 added in v0.6.9

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

func (*Request) Response added in v0.6.9

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

Response executes request client gets response mannually.

func (*Request) SetBasicAuth added in v0.6.9

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 added in v0.6.9

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

SetCookie add cookie into request.

func (*Request) SetEnableCookie added in v0.6.9

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

SetEnableCookie sets enable/disable cookiejar

func (*Request) SetProtocolVersion added in v0.6.9

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

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

func (*Request) SetProxy added in v0.6.9

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

Set 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 added in v0.6.9

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

SetTLSClientConfig sets tls connection configurations if visiting https url.

func (*Request) SetTimeout added in v0.6.9

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

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

func (*Request) SetTransport added in v0.6.9

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

Set transport to

func (*Request) SetUserAgent added in v0.6.9

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

SetUserAgent sets User-Agent header field

func (*Request) Setting added in v0.6.9

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

Change request settings

func (*Request) String added in v0.6.9

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

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

func (*Request) ToFile added in v0.6.9

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

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

func (*Request) ToJson added in v0.6.9

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 added in v0.6.9

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 added in v0.6.9

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
}

Jump to

Keyboard shortcuts

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