Documentation ¶
Overview ¶
Package http provides all HTTP (and FTP)-related operations
Index ¶
- func DownloadTemp(ctx context.Context, downloader aptly.Downloader, url string) (*os.File, error)
- func DownloadTempWithChecksum(ctx context.Context, downloader aptly.Downloader, url string, ...) (*os.File, error)
- func DownloadTryCompression(ctx context.Context, downloader aptly.Downloader, baseURL *url.URL, ...) (io.Reader, *os.File, error)
- func NewDownloader(downLimit int64, maxTries int, progress aptly.Progress) aptly.Downloader
- type Error
- type FakeDownloader
- func (f *FakeDownloader) AnyExpectResponse(url string, response string) *FakeDownloader
- func (f *FakeDownloader) Download(ctx context.Context, url string, filename string) error
- func (f *FakeDownloader) DownloadWithChecksum(ctx context.Context, url string, filename string, expected *utils.ChecksumInfo, ...) error
- func (f *FakeDownloader) Empty() bool
- func (f *FakeDownloader) ExpectError(url string, err error) *FakeDownloader
- func (f *FakeDownloader) ExpectResponse(url string, response string) *FakeDownloader
- func (f *FakeDownloader) GetLength(ctx context.Context, url string) (int64, error)
- func (f *FakeDownloader) GetProgress() aptly.Progress
- type GrabDownloader
- func (d *GrabDownloader) Download(ctx context.Context, url string, destination string) error
- func (d *GrabDownloader) DownloadWithChecksum(ctx context.Context, url string, destination string, ...) error
- func (d *GrabDownloader) GetLength(ctx context.Context, url string) (int64, error)
- func (d *GrabDownloader) GetProgress() aptly.Progress
- type NoCandidateFoundError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadTemp ¶
DownloadTemp starts new download to temporary file and returns File
Temporary file would be already removed, so no need to cleanup
func DownloadTempWithChecksum ¶
func DownloadTempWithChecksum(ctx context.Context, downloader aptly.Downloader, url string, expected *utils.ChecksumInfo, ignoreMismatch bool) (*os.File, error)
DownloadTempWithChecksum is a DownloadTemp with checksum verification
Temporary file would be already removed, so no need to cleanup
func DownloadTryCompression ¶
func DownloadTryCompression(ctx context.Context, downloader aptly.Downloader, baseURL *url.URL, path string, expectedChecksums map[string]utils.ChecksumInfo, ignoreMismatch bool) (io.Reader, *os.File, error)
DownloadTryCompression tries to download from URL .bz2, .gz and raw extension until it finds existing file.
func NewDownloader ¶
NewDownloader creates new instance of Downloader which specified number of threads and download limit in bytes/sec
Types ¶
type FakeDownloader ¶
type FakeDownloader struct {
// contains filtered or unexported fields
}
FakeDownloader is like Downloader, but it used in tests to stub out results
func NewFakeDownloader ¶
func NewFakeDownloader() *FakeDownloader
NewFakeDownloader creates new expected downloader
func (*FakeDownloader) AnyExpectResponse ¶
func (f *FakeDownloader) AnyExpectResponse(url string, response string) *FakeDownloader
AnyExpectResponse installs expectation on upcoming download with response in any order (url should be unique)
func (*FakeDownloader) Download ¶
Download performs fake download by matching against first expectation in the queue
func (*FakeDownloader) DownloadWithChecksum ¶
func (f *FakeDownloader) DownloadWithChecksum(ctx context.Context, url string, filename string, expected *utils.ChecksumInfo, ignoreMismatch bool) error
DownloadWithChecksum performs fake download by matching against first expectation in the queue or any expectation, with cheksum verification
func (*FakeDownloader) Empty ¶
func (f *FakeDownloader) Empty() bool
Empty verifies that are planned downloads have happened
func (*FakeDownloader) ExpectError ¶
func (f *FakeDownloader) ExpectError(url string, err error) *FakeDownloader
ExpectError installs expectation on upcoming download with error
func (*FakeDownloader) ExpectResponse ¶
func (f *FakeDownloader) ExpectResponse(url string, response string) *FakeDownloader
ExpectResponse installs expectation on upcoming download with response
func (*FakeDownloader) GetProgress ¶
func (f *FakeDownloader) GetProgress() aptly.Progress
GetProgress returns Progress object
type GrabDownloader ¶ added in v1.5.0
type GrabDownloader struct {
// contains filtered or unexported fields
}
func NewGrabDownloader ¶ added in v1.5.0
func NewGrabDownloader(downLimit int64, maxTries int, progress aptly.Progress) *GrabDownloader
NewGrabDownloader creates new expected downloader
func (*GrabDownloader) DownloadWithChecksum ¶ added in v1.5.0
func (d *GrabDownloader) DownloadWithChecksum(ctx context.Context, url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool) error
func (*GrabDownloader) GetProgress ¶ added in v1.5.0
func (d *GrabDownloader) GetProgress() aptly.Progress
type NoCandidateFoundError ¶ added in v1.4.0
NoCandidateFoundError indicates that now candidate of given url could be found
func (*NoCandidateFoundError) Error ¶ added in v1.4.0
func (e *NoCandidateFoundError) Error() string
Error message