Documentation ¶
Index ¶
- 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, ...) (*http.Response, 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) 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) 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)
- type RetryableConnection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClientBuilder ¶
func ClientBuilder() *httpClientBuilder
Types ¶
type ConcurrentDownloadFlags ¶
type ConnectHandler ¶
type DownloadFileDetails ¶
type DownloadFileDetails struct { FileName string `json:"LocalFileName,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 ¶
func (*HttpClient) DownloadFile ¶
func (jc *HttpClient) DownloadFile(downloadFileDetails *DownloadFileDetails, logMsgPrefix string, httpClientsDetails httputils.HttpClientDetails, retries int, 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.Progress) (*http.Response, 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, retries int) (*http.Response, string, error)
func (*HttpClient) DownloadFileWithProgress ¶
func (jc *HttpClient) DownloadFileWithProgress(downloadFileDetails *DownloadFileDetails, logMsgPrefix string, httpClientsDetails httputils.HttpClientDetails, retries int, isExplode bool, progress ioutils.Progress) (*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) 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) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendGet ¶
func (jc *HttpClient) SendGet(url string, followRedirect bool, httpClientsDetails httputils.HttpClientDetails) (resp *http.Response, respBody []byte, redirectUrl string, err error)
func (*HttpClient) SendHead ¶
func (jc *HttpClient) SendHead(url string, httpClientsDetails httputils.HttpClientDetails) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendPatch ¶
func (jc *HttpClient) SendPatch(url string, content []byte, httpClientsDetails httputils.HttpClientDetails) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendPost ¶
func (jc *HttpClient) SendPost(url string, content []byte, httpClientsDetails httputils.HttpClientDetails) (resp *http.Response, body []byte, err error)
func (*HttpClient) SendPut ¶
func (jc *HttpClient) SendPut(url string, content []byte, httpClientsDetails httputils.HttpClientDetails) (resp *http.Response, body []byte, err error)
func (*HttpClient) Stream ¶
func (jc *HttpClient) Stream(url string, httpClientsDetails httputils.HttpClientDetails) (*http.Response, []byte, string, error)
func (*HttpClient) UploadFile ¶
func (jc *HttpClient) UploadFile(localPath, url, logMsgPrefix string, httpClientsDetails httputils.HttpClientDetails, retries int, progress ioutils.Progress) (resp *http.Response, body []byte, err error)
You may implement the log.Progress interface, or pass nil to run without progress display.
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)