Documentation
¶
Index ¶
- Constants
- func DetectSize(targetURL, output string, showProgress 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 DownloadWithContinue(targetURL, output string, index, continueAt, end int64, showProgress bool) (err error)
- func GetExternalIP() (string, error)
- func SetProxy(proxy, proxyAuth string, tr *http.Transport) (err error)
- type DownloadError
- type HTTPDownloader
- type ProgressIndicator
- type RetryClient
Constants ¶
View Source
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 ¶
func DetectSize(targetURL, output string, showProgress bool) (total int64, rangeSupport bool, err error)
DetectSize 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
func DownloadFileWithMultipleThreadKeepParts ¶
func DownloadFileWithMultipleThreadKeepParts(targetURL, targetFilePath string, thread int, keepParts, showProgress bool) (err error)
DownloadFileWithMultipleThreadKeepParts downloads the files with multiple threads
func DownloadWithContinue ¶
func DownloadWithContinue(targetURL, output string, index, continueAt, end int64, showProgress bool) (err error)
DownloadWithContinue downloads the files continuously
func GetExternalIP ¶
GetExternalIP returns an external ip of current machine
Types ¶
type DownloadError ¶
DownloadError represents the error of HTTP download
type HTTPDownloader ¶
type HTTPDownloader struct {
TargetFilePath string
URL string
ShowProgress bool
InsecureSkipVerify bool
UserName string
Password string
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
}
HTTPDownloader is the downloader for http request
func (*HTTPDownloader) DownloadFile ¶
func (h *HTTPDownloader) DownloadFile() error
DownloadFile download a file with the progress
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) Init ¶
func (i *ProgressIndicator) Init()
Init set the default value for progress indicator
Click to show internal directories.
Click to hide internal directories.