httputils

package
v1.4.2-0...-4dd1d1b Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2015 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MimeTypes = struct {
	TextPlain   string
	Tar         string
	OctetStream string
}{"text/plain", "application/tar", "application/octet-stream"}

Functions

func DetectContentType

func DetectContentType(c []byte) (string, map[string]string, error)

DetectContentType returns a best guess representation of the MIME content type for the bytes at c. The value detected by http.DetectContentType is guaranteed not be nil, defaulting to application/octet-stream when a better guess cannot be made. The result of this detection is then run through mime.ParseMediaType() which separates it from any parameters. Note that calling this function does not advance the Reader at r

func Download

func Download(url string) (resp *http.Response, err error)

Download requests a given URL and returns an io.Reader

func NewHTTPRequestError

func NewHTTPRequestError(msg string, res *http.Response) error

NewHTTPRequestError returns a JSON response error

func ResumableRequestReader

func ResumableRequestReader(c *http.Client, r *http.Request, maxfail uint32, totalsize int64) io.ReadCloser

ResumableRequestReader makes it possible to resume reading a request's body transparently maxfail is the number of times we retry to make requests again (not resumes) totalsize is the total length of the body; auto detect if not provided

func ResumableRequestReaderWithInitialResponse

func ResumableRequestReaderWithInitialResponse(c *http.Client, r *http.Request, maxfail uint32, totalsize int64, initialResponse *http.Response) io.ReadCloser

ResumableRequestReaderWithInitialResponse makes it possible to resume reading the body of an already initiated request.

Types

This section is empty.

Jump to

Keyboard shortcuts

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