Skip to content

Commit

Permalink
Make downloader response public
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza authored and cmaglie committed Nov 12, 2020
1 parent 933d489 commit 1a18047
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions downloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
type Downloader struct {
URL string
Done chan bool
resp *http.Response
Resp *http.Response
out *os.File
completed int64
completedLock sync.Mutex
Expand All @@ -38,7 +38,7 @@ const (
// Close the download
func (d *Downloader) Close() error {
err1 := d.out.Close()
err2 := d.resp.Body.Close()
err2 := d.Resp.Body.Close()
if err1 != nil {
return fmt.Errorf("closing output file: %s", err1)
}
Expand Down Expand Up @@ -74,7 +74,7 @@ func (d *Downloader) RunAndPoll(poll func(current int64), interval time.Duration
// AsyncRun starts the downloader copy-loop. This function is supposed to be run
// on his own go routine because it sends a confirmation on the Done channel
func (d *Downloader) AsyncRun() {
in := d.resp.Body
in := d.Resp.Body
buff := [4096]byte{}
for {
n, err := in.Read(buff[:])
Expand Down Expand Up @@ -170,7 +170,7 @@ func DownloadWithConfig(file string, reqURL string, config Config, options ...Do
d := &Downloader{
URL: reqURL,
Done: make(chan bool),
resp: resp,
Resp: resp,
out: f,
completed: completed,
size: resp.ContentLength + completed,
Expand Down
2 changes: 1 addition & 1 deletion downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func TestApplyUserAgentHeaderUsingConfig(t *testing.T) {
require.NoError(t, err)

testEchoBody := echoBody{}
body, err := ioutil.ReadAll(d.resp.Body)
body, err := ioutil.ReadAll(d.Resp.Body)
require.NoError(t, err)
err = json.Unmarshal(body, &testEchoBody)
require.NoError(t, err)
Expand Down

0 comments on commit 1a18047

Please sign in to comment.