Documentation ¶
Index ¶
- func Do(req *fasthttp.Request, res *fasthttp.Response) error
- func DoDeadline(req *fasthttp.Request, res *fasthttp.Response, deadline time.Time) error
- func DoTimeout(req *fasthttp.Request, res *fasthttp.Response, timeout time.Duration) error
- func Download(w Writer, url string, contentLength int, acceptsRanges bool) error
- func DownloadBytes(dst []byte, url string) ([]byte, error)
- func DownloadBytesDeadline(dst []byte, url string, deadline time.Time) ([]byte, error)
- func DownloadBytesTimeout(dst []byte, url string, timeout time.Duration) ([]byte, error)
- func DownloadDeadline(w Writer, url string, contentLength int, acceptsRanges bool, ...) error
- func DownloadFile(filename, url string) error
- func DownloadFileDeadline(filename, url string, deadline time.Time) error
- func DownloadFileTimeout(filename, url string, timeout time.Duration) error
- func DownloadInChunks(w io.WriterAt, url string, length int) error
- func DownloadInChunksDeadline(w io.WriterAt, url string, length int, deadline time.Time) error
- func DownloadInChunksTimeout(w io.WriterAt, url string, length int, timeout time.Duration) error
- func DownloadSerially(w io.Writer, url string) error
- func DownloadSeriallyDeadline(w io.Writer, url string, deadline time.Time) error
- func DownloadSeriallyTimeout(w io.Writer, url string, timeout time.Duration) error
- func DownloadTimeout(w Writer, url string, contentLength int, acceptsRanges bool, ...) error
- func QueryHeaders(url string) (contentLength int, acceptsRanges bool)
- func QueryHeadersDeadline(url string, deadline time.Time) (contentLength int, acceptsRanges bool)
- func QueryHeadersTimeout(url string, timeout time.Duration) (contentLength int, acceptsRanges bool)
- type Client
- func (c *Client) Do(req *fasthttp.Request, res *fasthttp.Response) error
- func (c *Client) DoDeadline(req *fasthttp.Request, res *fasthttp.Response, deadline time.Time) error
- func (c *Client) DoTimeout(req *fasthttp.Request, res *fasthttp.Response, timeout time.Duration) error
- func (c *Client) Download(w Writer, url string, contentLength int, acceptsRanges bool) error
- func (c *Client) DownloadBytes(dst []byte, url string) ([]byte, error)
- func (c *Client) DownloadBytesDeadline(dst []byte, url string, deadline time.Time) ([]byte, error)
- func (c *Client) DownloadBytesTimeout(dst []byte, url string, timeout time.Duration) ([]byte, error)
- func (c *Client) DownloadDeadline(w Writer, url string, contentLength int, acceptsRanges bool, ...) error
- func (c *Client) DownloadFile(filename, url string) error
- func (c *Client) DownloadFileDeadline(filename, url string, deadline time.Time) error
- func (c *Client) DownloadFileTimeout(filename, url string, timeout time.Duration) error
- func (c *Client) DownloadInChunks(f io.WriterAt, url string, length int) error
- func (c *Client) DownloadInChunksDeadline(f io.WriterAt, url string, length int, deadline time.Time) error
- func (c *Client) DownloadInChunksTimeout(f io.WriterAt, url string, length int, timeout time.Duration) error
- func (c *Client) DownloadSerially(w io.Writer, url string) error
- func (c *Client) DownloadSeriallyDeadline(w io.Writer, url string, deadline time.Time) error
- func (c *Client) DownloadSeriallyTimeout(w io.Writer, url string, timeout time.Duration) error
- func (c *Client) DownloadTimeout(w Writer, url string, contentLength int, acceptsRanges bool, ...) error
- func (c *Client) QueryHeaders(url string) (contentLength int, acceptsRanges bool)
- func (c *Client) QueryHeadersDeadline(url string, deadline time.Time) (contentLength int, acceptsRanges bool)
- func (c *Client) QueryHeadersTimeout(url string, timeout time.Duration) (contentLength int, acceptsRanges bool)
- type Transport
- type WriteBuffer
- type Writer
- type WriterAtOffset
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do sends a HTTP request prescribed in req and populates its results into res. It additionally handles redirects unlike the de-facto Do(req, res) method in fasthttp.
func DoDeadline ¶
DoDeadline sends a HTTP request prescribed in req and populates its results into res. It additionally handles redirects unlike the de-facto Do(req, res) method in fasthttp. It overrides the default timeout set with a deadline.
func DoTimeout ¶
DoTimeout sends a HTTP request prescribed in req and populates its results into res. It additionally handles redirects unlike the de-facto Do(req, res) method in fasthttp. It overrides the default timeout set.
func DownloadBytes ¶
DownloadBytes downloads the contents of url, and returns them as a byte slice.
func DownloadBytesDeadline ¶
DownloadBytesDeadline downloads the contents of url, and returns them as a byte slice.
func DownloadBytesTimeout ¶
DownloadBytesTimeout downloads the contents of url, and returns them as a byte slice.
func DownloadDeadline ¶
func DownloadDeadline(w Writer, url string, contentLength int, acceptsRanges bool, deadline time.Time) error
DownloadDeadline downloads the contents of url and writes its contents to w.
func DownloadFile ¶
DownloadFile downloads of url, and writes its contents to a newly-created file titled filename.
func DownloadFileDeadline ¶
DownloadFileDeadline downloads of url, and writes its contents to a newly-created file titled filename.
func DownloadFileTimeout ¶
DownloadFileTimeout downloads of url, and writes its contents to a newly-created file titled filename.
func DownloadInChunks ¶
DownloadInChunks downloads file at url comprised of length bytes in chunks using multiple workers, and stores it in writer w.
func DownloadInChunksDeadline ¶
DownloadInChunksDeadline downloads file at url comprised of length bytes in chunks using multiple workers, and stores it in writer w.
func DownloadInChunksTimeout ¶
DownloadInChunksTimeout downloads file at url comprised of length bytes in chunks using multiple workers, and stores it in writer w.
func DownloadSerially ¶
DownloadSerially contents of url and writes it to w.
func DownloadSeriallyDeadline ¶
DownloadSeriallyDeadline contents of url and writes it to w.
func DownloadSeriallyTimeout ¶
DownloadSeriallyTimeout contents of url and writes it to w.
func DownloadTimeout ¶
func DownloadTimeout(w Writer, url string, contentLength int, acceptsRanges bool, timeout time.Duration) error
DownloadTimeout downloads the contents of url and writes its contents to w.
func QueryHeaders ¶
QueryHeaders learns from url its content length, and if it accepts parallel chunk fetching.
func QueryHeadersDeadline ¶
QueryHeadersDeadline learns from url its content length, and if it accepts parallel chunk fetching.
Types ¶
type Client ¶
type Client struct { // The underlying instance which nicehttp.Client wraps around. Instance Transport // Decide whether or not URLs that accept being downloaded in parallel chunks are handled with multiple workers. AcceptsRanges bool // The number of workers that are to be spawned for downloading chunks in parallel. NumWorkers int // Size of individual byte chunks downloaded. ChunkSize int // Max number of redirects to follow before a request is marked to have failed. MaxRedirectCount int }
Client wraps over fasthttp.Client a couple of useful helper functions.
func NewClient ¶
func NewClient() Client
NewClient instantiates a new nicehttp.Client with sane configuration defaults.
func WrapClient ¶
WrapClient wraps an existing fasthttp.Client or Transport into a nicehttp.Client.
func (*Client) Do ¶
Do sends a HTTP request prescribed in req and populates its results into res. It additionally handles redirects unlike the de-facto Do(req, res) method in fasthttp.
func (*Client) DoDeadline ¶
func (c *Client) DoDeadline(req *fasthttp.Request, res *fasthttp.Response, deadline time.Time) error
DoDeadline sends a HTTP request prescribed in req and populates its results into res. It additionally handles redirects unlike the de-facto Do(req, res) method in fasthttp. It overrides the default timeout set with a deadline.
func (*Client) DoTimeout ¶
func (c *Client) DoTimeout(req *fasthttp.Request, res *fasthttp.Response, timeout time.Duration) error
DoTimeout sends a HTTP request prescribed in req and populates its results into res. It additionally handles redirects unlike the de-facto Do(req, res) method in fasthttp. It overrides the default timeout set.
func (*Client) DownloadBytes ¶
DownloadBytes downloads the contents of url, and returns them as a byte slice.
func (*Client) DownloadBytesDeadline ¶
DownloadBytesDeadline downloads the contents of url, and returns them as a byte slice.
func (*Client) DownloadBytesTimeout ¶
func (c *Client) DownloadBytesTimeout(dst []byte, url string, timeout time.Duration) ([]byte, error)
DownloadBytesTimeout downloads the contents of url, and returns them as a byte slice.
func (*Client) DownloadDeadline ¶
func (c *Client) DownloadDeadline(w Writer, url string, contentLength int, acceptsRanges bool, deadline time.Time) error
DownloadDeadline downloads the contents of url and writes its contents to w.
func (*Client) DownloadFile ¶
DownloadFile downloads the contents of url, and writes its contents to a newly-created file titled filename.
func (*Client) DownloadFileDeadline ¶
DownloadFileDeadline downloads the contents of url, and writes its contents to a newly-created file titled filename.
func (*Client) DownloadFileTimeout ¶
DownloadFileTimeout downloads the contents of url, and writes its contents to a newly-created file titled filename.
func (*Client) DownloadInChunks ¶
DownloadInChunks downloads file at url comprised of length bytes in chunks using multiple workers, and stores it in writer w.
func (*Client) DownloadInChunksDeadline ¶
func (c *Client) DownloadInChunksDeadline(f io.WriterAt, url string, length int, deadline time.Time) error
DownloadInChunksDeadline downloads file at url comprised of length bytes in chunks using multiple workers, and stores it in writer w.
func (*Client) DownloadInChunksTimeout ¶
func (c *Client) DownloadInChunksTimeout(f io.WriterAt, url string, length int, timeout time.Duration) error
DownloadInChunksTimeout downloads file at url comprised of length bytes in chunks using multiple workers, and stores it in writer w.
func (*Client) DownloadSerially ¶
DownloadSerially serially downloads the contents of url and writes it to w.
func (*Client) DownloadSeriallyDeadline ¶
DownloadSeriallyDeadline serially downloads the contents of url and writes it to w.
func (*Client) DownloadSeriallyTimeout ¶
DownloadSeriallyTimeout serially downloads the contents of url and writes it to w.
func (*Client) DownloadTimeout ¶
func (c *Client) DownloadTimeout(w Writer, url string, contentLength int, acceptsRanges bool, timeout time.Duration) error
DownloadTimeout downloads the contents of url and writes its contents to w.
func (*Client) QueryHeaders ¶
QueryHeaders learns from url its content length, and if it accepts parallel chunk fetching.
type Transport ¶
type Transport interface { Do(req *fasthttp.Request, res *fasthttp.Response) error DoTimeout(req *fasthttp.Request, res *fasthttp.Response, timeout time.Duration) error DoDeadline(req *fasthttp.Request, res *fasthttp.Response, deadline time.Time) error }
Transport represents the interface of a HTTP client supported by nicehttp.
type WriteBuffer ¶
type WriteBuffer struct {
// contains filtered or unexported fields
}
WriteBuffer implements io.Writer and io.WriterAt on an optionally-provided byte slice.
func NewWriteBuffer ¶
func NewWriteBuffer(dst []byte) *WriteBuffer
NewWriteBuffer instantiates a new write buffer around dst. dst may be nil.
func (*WriteBuffer) Bytes ¶
func (b *WriteBuffer) Bytes() []byte
Bytes returns the underlying byte slice.
type WriterAtOffset ¶
type WriterAtOffset struct {
// contains filtered or unexported fields
}
WriterAtOffset implements io.Writer for a given io.WriterAt at an offset.
func NewWriterAtOffset ¶
func NewWriterAtOffset(dst io.WriterAt, offset int64) *WriterAtOffset
NewWriterAtOffset instantiates a new writer at a specified offset.