Documentation ¶
Index ¶
- Variables
- func ByteUnitString(n int64) string
- type Chunk
- type Download
- func (d *Download) AvgSpeed() uint64
- func (d *Download) ChunkInit() (err error)
- func (d *Download) ChunkStart() (err error)
- func (d *Download) DownloadChunk(c *Chunk, dest io.Writer) error
- func (d *Download) GetInfoOrDownload() (*Info, error)
- func (d *Download) IsRangeable() bool
- func (d *Download) Path() string
- func (d *Download) RunProgress()
- func (d *Download) Size() uint64
- func (d *Download) Speed() uint64
- func (d *Download) TotalCost() time.Duration
- func (d *Download) TotalSize() uint64
- func (d *Download) Write(b []byte) (int, error)
- type Info
- type OffsetWriter
- type Options
- type Request
- func (r *Request) Delete(uri string, opts ...Options) (*Response, error)
- func (r *Request) FastGet(uri string, opts ...Options) (resp *Response, err error)
- func (r *Request) Get(uri string, opts ...Options) (*Response, error)
- func (r *Request) Options(uri string, opts ...Options) (*Response, error)
- func (r *Request) Patch(uri string, opts ...Options) (*Response, error)
- func (r *Request) Post(uri string, opts ...Options) (*Response, error)
- func (r *Request) Put(uri string, opts ...Options) (*Response, error)
- func (r *Request) Request(method, uri string, opts ...Options) (*Request, error)
- type Response
- func Delete(c context.Context, uri string, opts ...Options) (*Response, error)
- func FastGet(c context.Context, uri string, opts ...Options) (*Response, error)
- func Get(c context.Context, uri string, opts ...Options) (*Response, error)
- func Patch(c context.Context, uri string, opts ...Options) (*Response, error)
- func Post(c context.Context, uri string, opts ...Options) (*Response, error)
- func Put(c context.Context, uri string, opts ...Options) (*Response, error)
- func (r *Response) GetBody() (ResponseBody, error)
- func (r *Response) GetCookies() []*http.Cookie
- func (r *Response) GetHeader(name string) []string
- func (r *Response) GetHeaderLine(name string) string
- func (r *Response) GetHeaders() map[string][]string
- func (r *Response) GetJsonDecodeBody(body interface{}) (err error)
- func (r *Response) GetReasonPhrase() string
- func (r *Response) GetRequest() *http.Request
- func (r *Response) GetStatusCode() int
- func (r *Response) HasHeader(name string) bool
- func (r *Response) IsTimeout() bool
- type ResponseBody
Constants ¶
This section is empty.
Variables ¶
var DefaultFileName = "gohttp.output"
DefaultFileName is the fallback name for GetFilename.
Functions ¶
func ByteUnitString ¶
Types ¶
type Download ¶
type Download struct { Cookie []http.Cookie Concurrency uint StopProgress bool URL, Dir, Dest string Interval, ChunkSize, MinChunkSize, MaxChunkSize uint64 // contains filtered or unexported fields }
Download holds downloadable file config and infos.
func (*Download) ChunkInit ¶
Init set defaults and split file into chunks and gets Info, you should call Init before Start
func (*Download) ChunkStart ¶
Start downloads the file chunks, and merges them. Must be called only after init
func (*Download) DownloadChunk ¶
DownloadChunk downloads a file chunk.
func (*Download) GetInfoOrDownload ¶
Try downloading the first byte of the file using a range request. If the server supports range requests, then we'll extract the length info from content-range, Otherwise this just downloads the whole file in one go
func (*Download) IsRangeable ¶
IsRangeable returns file server partial content support state.
func (*Download) RunProgress ¶
func (d *Download) RunProgress()
RunProgress runs ProgressFunc based on Interval and updates lastSize.
type OffsetWriter ¶
type Options ¶
type Options struct { Debug bool Concurrency uint //CPU核数 BaseURI string Timeout float32 Query interface{} Headers map[string]interface{} Cookies interface{} CookieFile string CookieJar *cookiejar.Jar FormParams map[string]interface{} JSON interface{} Body []byte XML interface{} Proxy string DestFile string //保存到本地文件 Overwrite bool //覆蓋文件 // contains filtered or unexported fields }
Options object
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request object
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response response object
func (*Response) GetBody ¶
func (r *Response) GetBody() (ResponseBody, error)
GetBody parse response body
func (*Response) GetCookies ¶
Cookies get if header exsits in response headers
func (*Response) GetHeaderLine ¶
GetHeaderLine get a single response header
func (*Response) GetHeaders ¶
GetHeaders get response headers
func (*Response) GetJsonDecodeBody ¶
GetParsedBody parse response body
func (*Response) GetReasonPhrase ¶
GetReasonPhrase get response reason phrase
func (*Response) GetRequest ¶
GetRequest get request object
func (*Response) GetStatusCode ¶
GetStatusCode get response status code
type ResponseBody ¶
type ResponseBody []byte
ResponseBody response body
func (ResponseBody) GetContents ¶
func (r ResponseBody) GetContents() string
GetContents format response body as string
func (ResponseBody) Read ¶
func (r ResponseBody) Read(length int) []byte
Read get slice of response body