cavaliergopher / grab

A download manager package for Go
BSD 3-Clause "New" or "Revised" License
1.38k stars 151 forks source link

Requests following a 302 response will result in ErrBadLength #20

Open zhiwei-nu opened 6 years ago

zhiwei-nu commented 6 years ago

Currently if I try to download a file that gives a 302 response, the Content-Length retrieved will be incorrect and cause the download to fail

Edit: Made some changes for my use case to work, the failing part is here:

    if size < c.fi.Size() {
        fmt.Printf("Expected %v, Got %v\n", size, c.fi.Size())
        // return false, ErrBadLength
    }

Expected 2023597, Got 2023599

wagoodman commented 6 years ago

Also got this issue, here is a gist to reproduce (fails on the second run): https://gist.github.com/wagoodman/371c446fbde051f94d8eac1cddc3bf73