Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Download ¶
type Download struct { // net/http.Client to use when downloading the update. // If nil, a default http.Client is used HttpClient *http.Client // As bytes are downloaded, they are written to Target. // Download also uses the Target's Seek method to determine // the size of partial-downloads so that it may properly // request the remaining bytes to resume the download. Target Target // Progress returns the percentage of the download // completed as an integer between 0 and 100 Progress chan (int) // HTTP Method to use in the download request. Default is "GET" Method string // HTTP URL to issue the download request to Url string }
Download encapsulates the state and parameters to download content from a URL which:
- Publishes the percentage of the download completed to a channel. - May resume a previous download that was partially completed.
Create an instance with the New() factory function.
func New ¶
New initializes a new Download object which will download the content from url into target.
func (*Download) Get ¶
Get() downloads the content of a url to a target destination.
Only HTTP/1.1 servers that implement the Range header support resuming a partially completed download.
On success, the server must return 200 and the content, or 206 when resuming a partial download. If the HTTP server returns a 3XX redirect, it will be followed according to d.HttpClient's redirect policy.
type FileTarget ¶
func (*FileTarget) Size ¶
func (t *FileTarget) Size() (int, error)
type MemoryTarget ¶
func (*MemoryTarget) Size ¶
func (t *MemoryTarget) Size() (int, error)