Documentation
¶
Index ¶
- Variables
- func CacheFilename(url string) string
- func Download(host hostActions, r Request) (string, error)
- func DownloadToGuest(host hostActions, guest guestActions, r Request, filename string) error
- type DownloadOptions
- type DownloadResult
- type HTTPClient
- type HTTPStatusError
- type NetworkError
- type Request
- type ResumeError
- type ResumeInfo
- type SHA
- type SHAValidationError
Constants ¶
This section is empty.
Variables ¶
var ( ErrNetworkConnection = errors.New("network connection error") ErrHTTPStatus = errors.New("HTTP error") ErrResumeFailed = errors.New("resume failed") ErrSHAValidation = errors.New("SHA validation failed") )
Sentinel errors for type checking
Functions ¶
func CacheFilename ¶ added in v0.7.0
CacheFilename returns the computed filename for the url.
func DownloadToGuest ¶ added in v0.7.0
DownloadToGuest downloads file at url and saves it in the destination.
In the implementation, the file is downloaded (and cached) on the host, but copied to the desired destination for the guest. filename must be an absolute path and a directory on the guest that does not require root access.
Types ¶
type DownloadOptions ¶ added in v0.10.0
type DownloadOptions struct {
URL string
DestPath string
ExpectedETag string // for resume validation
ResumeFromByte int64 // byte offset to resume from
ShowProgress bool
}
DownloadOptions configures a download operation
type DownloadResult ¶ added in v0.10.0
type DownloadResult struct {
FinalURL string // After following redirects
ETag string // For future resume validation
TotalBytes int64
WasResumed bool
}
DownloadResult contains metadata about the completed download
type HTTPClient ¶ added in v0.10.0
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient encapsulates HTTP download operations
func NewHTTPClient ¶ added in v0.10.0
func NewHTTPClient() *HTTPClient
NewHTTPClient creates a configured HTTP client
func (*HTTPClient) Download ¶ added in v0.10.0
func (h *HTTPClient) Download(ctx context.Context, opts DownloadOptions) (*DownloadResult, error)
Download performs a file download with optional resume support
func (*HTTPClient) Fetch ¶ added in v0.10.0
Fetch downloads content from a URL and returns it as bytes (for small files like SHA checksums)
func (*HTTPClient) GetFinalURL ¶ added in v0.10.0
GetFinalURL follows redirects and returns the final URL
type HTTPStatusError ¶ added in v0.10.0
HTTPStatusError represents HTTP error responses
func (*HTTPStatusError) Error ¶ added in v0.10.0
func (e *HTTPStatusError) Error() string
func (*HTTPStatusError) Unwrap ¶ added in v0.10.0
func (e *HTTPStatusError) Unwrap() error
type NetworkError ¶ added in v0.10.0
NetworkError wraps network-related errors with user-friendly messages
func (*NetworkError) Error ¶ added in v0.10.0
func (e *NetworkError) Error() string
func (*NetworkError) Unwrap ¶ added in v0.10.0
func (e *NetworkError) Unwrap() error
type ResumeError ¶ added in v0.10.0
ResumeError indicates a failed resume attempt
func (*ResumeError) Error ¶ added in v0.10.0
func (e *ResumeError) Error() string
func (*ResumeError) Unwrap ¶ added in v0.10.0
func (e *ResumeError) Unwrap() error
type ResumeInfo ¶ added in v0.10.0
ResumeInfo stores metadata for resumable downloads
type SHA ¶ added in v0.6.0
type SHA struct {
Digest string // shasum
URL string // url to download the shasum file (if Digest is empty)
Size int // one of 256 or 512
}
SHA is the shasum of a file.
func (SHA) ValidateFile ¶ added in v0.8.1
ValidateFile validates the SHA of the file. The host parameter is kept for API compatibility but is not used.
type SHAValidationError ¶ added in v0.10.0
SHAValidationError indicates checksum mismatch
func (*SHAValidationError) Error ¶ added in v0.10.0
func (e *SHAValidationError) Error() string
func (*SHAValidationError) Unwrap ¶ added in v0.10.0
func (e *SHAValidationError) Unwrap() error