Documentation ¶
Index ¶
- Variables
- func ClientBuilder() *httpClientBuilder
- type ConcurrentDownloadFlags
- type ConnectHandler
- type DownloadFileDetails
- type ErrorHandler
- type HttpClient
- func (jc *HttpClient) DownloadFile(downloadFileDetails *DownloadFileDetails, logMsgPrefix string, ...) (*http.Response, error)
- func (jc *HttpClient) DownloadFileConcurrently(flags ConcurrentDownloadFlags, logMsgPrefix string, ...) (resp *http.Response, err error)
- func (jc *HttpClient) DownloadFileNoRedirect(downloadPath, localPath, fileName string, ...) (*http.Response, string, error)
- func (jc *HttpClient) DownloadFileWithProgress(downloadFileDetails *DownloadFileDetails, logMsgPrefix string, ...) (*http.Response, error)
- func (jc *HttpClient) GetRemoteFileDetails(downloadUrl string, httpClientsDetails httputils.HttpClientDetails) (*fileutils.FileDetails, *http.Response, error)
- func (jc *HttpClient) GetRetries() int
- func (jc *HttpClient) GetRetryWaitTime() int
- func (jc *HttpClient) IsAcceptRanges(downloadUrl string, httpClientsDetails httputils.HttpClientDetails) (bool, *http.Response, error)
- func (jc *HttpClient) ReadRemoteFile(downloadPath string, httpClientsDetails httputils.HttpClientDetails) (io.ReadCloser, *http.Response, error)
- func (jc *HttpClient) Send(method, url string, content []byte, followRedirect, closeBody bool, ...) (resp *http.Response, respBody []byte, redirectUrl string, err error)
- func (jc *HttpClient) SendDelete(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, ...) (resp *http.Response, body []byte, err error)
- func (jc *HttpClient) SendGet(url string, followRedirect bool, ...) (resp *http.Response, respBody []byte, redirectUrl string, err error)
- func (jc *HttpClient) SendHead(url string, httpClientsDetails httputils.HttpClientDetails, ...) (resp *http.Response, body []byte, err error)
- func (jc *HttpClient) SendPatch(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, ...) (resp *http.Response, body []byte, err error)
- func (jc *HttpClient) SendPost(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, ...) (resp *http.Response, body []byte, err error)
- func (jc *HttpClient) SendPostLeaveBodyOpen(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, ...) (resp *http.Response, err error)
- func (jc *HttpClient) SendPut(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, ...) (resp *http.Response, body []byte, err error)
- func (jc *HttpClient) Stream(url string, httpClientsDetails httputils.HttpClientDetails, ...) (*http.Response, []byte, string, error)
- func (jc *HttpClient) UploadFile(localPath, url, logMsgPrefix string, ...) (resp *http.Response, body []byte, err error)
- func (jc *HttpClient) UploadFileFromReader(reader io.Reader, url string, httpClientsDetails httputils.HttpClientDetails, ...) (resp *http.Response, body []byte, err error)
- type RetryableConnection
Constants ¶
This section is empty.
Variables ¶
var DefaultHttpTimeout = 30 * time.Second
Functions ¶
func ClientBuilder ¶
func ClientBuilder() *httpClientBuilder
Types ¶
type ConcurrentDownloadFlags ¶
type ConnectHandler ¶
type DownloadFileDetails ¶
type DownloadFileDetails struct { FileName string `json:"FileName,omitempty"` DownloadPath string `json:"DownloadPath,omitempty"` RelativePath string `json:"RelativePath,omitempty"` LocalPath string `json:"LocalPath,omitempty"` LocalFileName string `json:"LocalFileName,omitempty"` ExpectedSha1 string `json:"ExpectedSha1,omitempty"` Size int64 `json:"Size,omitempty"` }
type ErrorHandler ¶
type HttpClient ¶
type HttpClient struct {
// contains filtered or unexported fields
}
func (*HttpClient) DownloadFile ¶
func (jc *HttpClient) DownloadFile(downloadFileDetails *DownloadFileDetails, logMsgPrefix string, httpClientsDetails httputils.HttpClientDetails, isExplode bool) (*http.Response, error)
Bulk downloads a file.
func (*HttpClient) DownloadFileConcurrently ¶
func (jc *HttpClient) DownloadFileConcurrently(flags ConcurrentDownloadFlags, logMsgPrefix string, httpClientsDetails httputils.HttpClientDetails, progress ioutils.ProgressMgr) (resp *http.Response, err error)
Downloads a file by chunks, concurrently. If successful, returns the resp of the last chunk, which will have resp.StatusCode = http.StatusPartialContent Otherwise: if an error occurred - returns the error with resp=nil, else - err=nil and the resp of the first chunk that received statusCode!=http.StatusPartialContent The caller is responsible to check the resp.StatusCode. You may implement the log.Progress interface, or pass nil to run without progress display.
func (*HttpClient) DownloadFileNoRedirect ¶
func (jc *HttpClient) DownloadFileNoRedirect(downloadPath, localPath, fileName string, httpClientsDetails httputils.HttpClientDetails) (*http.Response, string, error)
func (*HttpClient) DownloadFileWithProgress ¶
func (jc *HttpClient) DownloadFileWithProgress(downloadFileDetails *DownloadFileDetails, logMsgPrefix string, httpClientsDetails httputils.HttpClientDetails, isExplode bool, progress ioutils.ProgressMgr) (*http.Response, error)
Bulk downloads a file. You may implement the log.Progress interface, or pass nil to run without progress display.
func (*HttpClient) GetRemoteFileDetails ¶
func (jc *HttpClient) GetRemoteFileDetails(downloadUrl string, httpClientsDetails httputils.HttpClientDetails) (*fileutils.FileDetails, *http.Response, error)
The caller is responsible to check that resp.StatusCode is http.StatusOK
func (*HttpClient) GetRetries ¶ added in v0.25.0
func (jc *HttpClient) GetRetries() int
func (*HttpClient) GetRetryWaitTime ¶ added in v1.7.0
func (jc *HttpClient) GetRetryWaitTime() int
func (*HttpClient) IsAcceptRanges ¶
func (jc *HttpClient) IsAcceptRanges(downloadUrl string, httpClientsDetails httputils.HttpClientDetails) (bool, *http.Response, error)
The caller is responsible to check if resp.StatusCode is StatusOK before relying on the bool value
func (*HttpClient) ReadRemoteFile ¶
func (jc *HttpClient) ReadRemoteFile(downloadPath string, httpClientsDetails httputils.HttpClientDetails) (io.ReadCloser, *http.Response, error)
Read remote file, The caller is responsible to check if resp.StatusCode is StatusOK before reading, and to close io.ReadCloser after done reading.
func (*HttpClient) SendDelete ¶
func (jc *HttpClient) SendDelete(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, logMsgPrefix string) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendHead ¶
func (jc *HttpClient) SendHead(url string, httpClientsDetails httputils.HttpClientDetails, logMsgPrefix string) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendPatch ¶
func (jc *HttpClient) SendPatch(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, logMsgPrefix string) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendPost ¶
func (jc *HttpClient) SendPost(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, logMsgPrefix string) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendPostLeaveBodyOpen ¶
func (jc *HttpClient) SendPostLeaveBodyOpen(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, logMsgPrefix string) (resp *http.Response, err error)
func (*HttpClient) SendPut ¶
func (jc *HttpClient) SendPut(url string, content []byte, httpClientsDetails httputils.HttpClientDetails, logMsgPrefix string) (resp *http.Response, body []byte, err error)
func (*HttpClient) Stream ¶
func (jc *HttpClient) Stream(url string, httpClientsDetails httputils.HttpClientDetails, logMsgPrefix string) (*http.Response, []byte, string, error)
func (*HttpClient) UploadFile ¶
func (jc *HttpClient) UploadFile(localPath, url, logMsgPrefix string, httpClientsDetails httputils.HttpClientDetails, progress ioutils.ProgressMgr) (resp *http.Response, body []byte, err error)
You may implement the log.Progress interface, or pass nil to run without progress display.
func (*HttpClient) UploadFileFromReader ¶ added in v0.20.1
type RetryableConnection ¶
type RetryableConnection struct { // ReadTimeout, if read timeout time passes without any data received from the server the connection will be closed. ReadTimeout time.Duration // RetriesNum represents the number of retries following a lost connection, -1 for unlimited RetriesNum int // StableConnectionWindow sets the duration of a stable connection after which the RetriesNum is reset. // If 0 RetriesNum is never reset. // It is recommended to use longer time than ReadTimeout. StableConnectionWindow time.Duration // SleepBetweenRetries sleep time between two retires. SleepBetweenRetries time.Duration // ConnectHandler will be called for connection retry, make sure response body is not closed. ConnectHandler ConnectHandler // ErrorHandler will be called after successful connection for content errors checks. ErrorHandler ErrorHandler }
func (*RetryableConnection) Do ¶
func (rt *RetryableConnection) Do() ([]byte, error)