Disable compression when downloading, otherwise HTTP client may do "decompression" on its own. #33

This commit is contained in:
Andrey Smirnov
2014-04-16 15:55:04 +04:00
parent cefc3cc2dc
commit 6352ce30ed
+3 -1
View File
@@ -28,6 +28,7 @@ type downloaderImpl struct {
unpause chan bool
progress aptly.Progress
threads int
client *http.Client
}
// downloadTask represents single item in queue
@@ -50,6 +51,7 @@ func NewDownloader(threads int, progress aptly.Progress) aptly.Downloader {
unpause: make(chan bool),
threads: threads,
progress: progress,
client: &http.Client{Transport: &http.Transport{DisableCompression: true}},
}
for i := 0; i < downloader.threads; i++ {
@@ -105,7 +107,7 @@ func (downloader *downloaderImpl) DownloadWithChecksum(url string, destination s
func (downloader *downloaderImpl) handleTask(task *downloadTask) {
downloader.progress.Printf("Downloading %s...\n", task.url)
resp, err := http.Get(task.url)
resp, err := downloader.client.Get(task.url)
if err != nil {
task.result <- err
return