http

package
v1.5.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2023 License: MIT Imports: 26 Imported by: 2

Documentation

Overview

Package http provides all HTTP (and FTP)-related operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadTemp

func DownloadTemp(ctx context.Context, downloader aptly.Downloader, url string) (*os.File, error)

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

func NewDownloader(downLimit int64, maxTries int, progress aptly.Progress) aptly.Downloader

NewDownloader creates new instance of Downloader which specified number of threads and download limit in bytes/sec

Types

type Error added in v1.0.0

type Error struct {
	Code int
	URL  string
}

Error is download error connected to HTTP code

func (*Error) Error added in v1.0.0

func (e *Error) Error() string

Error

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

func (f *FakeDownloader) Download(ctx context.Context, url string, filename string) error

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) GetLength added in v1.4.0

func (f *FakeDownloader) GetLength(ctx context.Context, url string) (int64, error)

GetLength returns content length of given url

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) Download added in v1.5.0

func (d *GrabDownloader) Download(ctx context.Context, url string, destination string) error

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) GetLength added in v1.5.0

func (d *GrabDownloader) GetLength(ctx context.Context, url string) (int64, error)

func (*GrabDownloader) GetProgress added in v1.5.0

func (d *GrabDownloader) GetProgress() aptly.Progress

type NoCandidateFoundError added in v1.4.0

type NoCandidateFoundError struct {
	URL *url.URL
}

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL