Closed ViRb3 closed 3 years ago
It seems my automated GitHub tests broke some time ago. Do all tests pass for this diff?
I believe they pass.
root@grab# go test ./...
ok github.com/cavaliercoder/grab 2.554s
ok github.com/cavaliercoder/grab/bps 0.037s
? github.com/cavaliercoder/grab/cmd/grab [no test files]
ok github.com/cavaliercoder/grab/grabtest 0.180s
? github.com/cavaliercoder/grab/grabui [no test files]
Love it. Thank you for submitting this diff!
First of all thank you so much for this amazing library!
I'm attempting to download files from a host that uses a CDN. The host only acts as a resolver, so every response will be a redirect to the appropriate CDN resource. Now, imagine a file is only partially downloaded, and grab is attempting to resume. It will send a HEAD request to the host, which will redirect to the CDN, and the CDN will say that it supports partial downloads (
Range
). Grab will then proceed to send a GET request withRange
header to the host, which returns 404 because it does not supportRange
- it was the CDN that advertised support for it. The correct scenario here, in my opinion, is to remember the redirect destination during The HEAD operation, and use that for future requests. This is what this CR achieves, in 2 lines of code :)