Documentation ¶
Overview ¶
Package net provides net related functions
Index ¶
- Constants
- func DetectSize(targetURL, output string, showProgress bool) (int64, bool, error)
- func DetectSizeWithRoundTripper(targetURL, output string, showProgress bool, noProxy bool, ...) (total int64, rangeSupport bool, err error)
- func DownloadFileWithMultipleThread(targetURL, targetFilePath string, thread int, showProgress bool) (err error)
- func DownloadFileWithMultipleThreadKeepParts(targetURL, targetFilePath string, thread int, keepParts, showProgress bool) (err error)
- func SetProxy(proxy, proxyAuth string, tr *http.Transport) (err error)
- type ContinueDownloader
- func (c *ContinueDownloader) DownloadWithContinue(targetURL, output string, index, continueAt, end int64, showProgress bool) (err error)
- func (c *ContinueDownloader) WithRoundTripper(roundTripper http.RoundTripper) *ContinueDownloader
- func (c *ContinueDownloader) WithoutProxy(noProxy bool) *ContinueDownloader
- type DownloadError
- type FakeReader
- type HTTPDownloader
- type MultiThreadDownloader
- func (d *MultiThreadDownloader) Download(targetURL, targetFilePath string, thread int) (err error)
- func (d *MultiThreadDownloader) WithKeepParts(keepParts bool) *MultiThreadDownloader
- func (d *MultiThreadDownloader) WithRoundTripper(roundTripper http.RoundTripper) *MultiThreadDownloader
- func (d *MultiThreadDownloader) WithShowProgress(showProgress bool) *MultiThreadDownloader
- func (d *MultiThreadDownloader) WithoutProxy(noProxy bool) *MultiThreadDownloader
- type ProgressIndicator
- type RetryClient
Constants ¶
const ( // ContentType is for the http header of content type ContentType = "Content-Type" // ApplicationForm is for the form submit ApplicationForm = "application/x-www-form-urlencoded" )
Variables ¶
This section is empty.
Functions ¶
func DetectSize ¶
DetectSize returns the size of target resource
Deprecated, use DetectSizeWithRoundTripper instead
func DetectSizeWithRoundTripper ¶ added in v0.0.68
func DetectSizeWithRoundTripper(targetURL, output string, showProgress bool, noProxy bool, roundTripper http.RoundTripper) (total int64, rangeSupport bool, err error)
DetectSizeWithRoundTripper returns the size of target resource
func DownloadFileWithMultipleThread ¶
func DownloadFileWithMultipleThread(targetURL, targetFilePath string, thread int, showProgress bool) (err error)
DownloadFileWithMultipleThread downloads the files with multiple threads
Types ¶
type ContinueDownloader ¶ added in v0.0.32
type ContinueDownloader struct {
// contains filtered or unexported fields
}
ContinueDownloader is a downloader which support continuously download
func (*ContinueDownloader) DownloadWithContinue ¶ added in v0.0.32
func (c *ContinueDownloader) DownloadWithContinue(targetURL, output string, index, continueAt, end int64, showProgress bool) (err error)
DownloadWithContinue downloads the files continuously
func (*ContinueDownloader) WithRoundTripper ¶ added in v0.0.69
func (c *ContinueDownloader) WithRoundTripper(roundTripper http.RoundTripper) *ContinueDownloader
WithRoundTripper set WithRoundTripper
func (*ContinueDownloader) WithoutProxy ¶ added in v0.0.69
func (c *ContinueDownloader) WithoutProxy(noProxy bool) *ContinueDownloader
WithoutProxy indicate no HTTP proxy use
type DownloadError ¶
DownloadError represents the error of HTTP download
type FakeReader ¶ added in v0.0.77
type FakeReader struct {
ExpectErr error
}
FakeReader is a fake reader for the test purpose
type HTTPDownloader ¶
type HTTPDownloader struct { TargetFilePath string URL string ShowProgress bool InsecureSkipVerify bool UserName string Password string NoProxy bool Proxy string ProxyAuth string Header map[string]string // PreStart returns false will don't continue PreStart func(*http.Response) bool Thread int Title string Timeout int MaxAttempts int Debug bool RoundTripper http.RoundTripper // contains filtered or unexported fields }
HTTPDownloader is the downloader for http request
func (*HTTPDownloader) DownloadFile ¶
func (h *HTTPDownloader) DownloadFile() error
DownloadFile download a file with the progress
type MultiThreadDownloader ¶ added in v0.0.69
type MultiThreadDownloader struct {
// contains filtered or unexported fields
}
MultiThreadDownloader is a download with multi-thread
func (*MultiThreadDownloader) Download ¶ added in v0.0.69
func (d *MultiThreadDownloader) Download(targetURL, targetFilePath string, thread int) (err error)
Download starts to download the target URL
func (*MultiThreadDownloader) WithKeepParts ¶ added in v0.0.69
func (d *MultiThreadDownloader) WithKeepParts(keepParts bool) *MultiThreadDownloader
WithKeepParts indicates if keeping the part files
func (*MultiThreadDownloader) WithRoundTripper ¶ added in v0.0.69
func (d *MultiThreadDownloader) WithRoundTripper(roundTripper http.RoundTripper) *MultiThreadDownloader
WithRoundTripper sets RoundTripper
func (*MultiThreadDownloader) WithShowProgress ¶ added in v0.0.69
func (d *MultiThreadDownloader) WithShowProgress(showProgress bool) *MultiThreadDownloader
WithShowProgress indicate if show the download progress
func (*MultiThreadDownloader) WithoutProxy ¶ added in v0.0.69
func (d *MultiThreadDownloader) WithoutProxy(noProxy bool) *MultiThreadDownloader
WithoutProxy indicates not use HTTP proxy
type ProgressIndicator ¶
type ProgressIndicator struct { Writer io.Writer Reader io.Reader Title string // bytes.Buffer Total float64 // contains filtered or unexported fields }
ProgressIndicator hold the progress of io operation
func (ProgressIndicator) Close ¶ added in v0.0.32
func (i ProgressIndicator) Close()
Close shutdowns the ui process
func (*ProgressIndicator) Init ¶
func (i *ProgressIndicator) Init()
Init set the default value for progress indicator