http

package
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2020 License: Apache-2.0 Imports: 13 Imported by: 51

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client defines an http client object

func (*Client) DownloadFile added in v1.14.0

func (c *Client) DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error

DownloadFile downloads a file's content as GET request from the specified URL to the specified file

func (*Client) DownloadRequest added in v1.14.0

func (c *Client) DownloadRequest(method, url, filename string, header http.Header, cookies []*http.Cookie) error

DownloadRequest ...

func (*Client) SendRequest

func (c *Client) SendRequest(method, url string, body io.Reader, header http.Header, cookies []*http.Cookie) (*http.Response, error)

SendRequest sends an http request with a defined method

func (*Client) SetOptions

func (c *Client) SetOptions(options ClientOptions)

SetOptions sets options used for the http client

func (*Client) UploadFile added in v1.9.0

func (c *Client) UploadFile(url, file, fieldName string, header http.Header, cookies []*http.Cookie) (*http.Response, error)

UploadFile uploads a file's content as multipart-form POST request to the specified URL

func (*Client) UploadRequest added in v1.10.0

func (c *Client) UploadRequest(method, url, file, fieldName string, header http.Header, cookies []*http.Cookie) (*http.Response, error)

UploadRequest uploads a file's content as multipart-form with given http method request to the specified URL

type ClientOptions

type ClientOptions struct {
	// MaxRequestDuration has a default value of "0", meaning "no maximum
	// request duration". If it is greater than 0, an overall, hard timeout
	// for the request will be enforced. This should only be used if the
	// length of the request bodies is known.
	MaxRequestDuration time.Duration
	// TransportTimeout defaults to 10 seconds, if not specified. It is
	// used for the transport layer and duration of handshakes and such.
	TransportTimeout time.Duration
	Username         string
	Password         string
	Token            string
	Logger           *logrus.Entry
	CookieJar        http.CookieJar
}

ClientOptions defines the options to be set on the client

type Downloader added in v1.14.0

type Downloader interface {
	SetOptions(options ClientOptions)
	DownloadFile(url, filename string, header http.Header, cookies []*http.Cookie) error
}

Downloader ...

type Sender

type Sender interface {
	SendRequest(method, url string, body io.Reader, header http.Header, cookies []*http.Cookie) (*http.Response, error)
	SetOptions(options ClientOptions)
}

Sender provides an interface to the piper http client for uid/pwd and token authenticated requests

type Uploader added in v1.9.0

type Uploader interface {
	Sender
	UploadRequest(method, url, file, fieldName string, header http.Header, cookies []*http.Cookie) (*http.Response, error)
	UploadFile(url, file, fieldName string, header http.Header, cookies []*http.Cookie) (*http.Response, error)
}

Uploader provides an interface to the piper http client for uid/pwd and token authenticated requests with upload capabilities

Jump to

Keyboard shortcuts

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