Closed setnicka closed 4 years ago
Would you consider writing tests the cover the following cases?
Thanks for raising this. It definitely needs addressing.
Possible values for ContentLength
are documented in https://golang.org/pkg/net/http/#Response
I changed checks - now it directly checks HTTPResponse.ContentLength. In addition I implemented tests to check behavior for normal and resumed downloads.
I think it now should cover all cases (if I am not missing something).
Hello, would you find some time to review this pull request? :-)
Thanks for your patience with this. Your code looks great, but there are so many possible states for this package - I need to be really cautious. I'm certain my tests are failing to cover some nuanced edge-case with this scenario. I'll try take a thorough look this weekend and get it merged.
Hi @cavaliercoder, something new about it? :-)
Since rebasing, a couple of the checksum tests are failing, so we'll need to address that. Your test looks good, but I'd like to split it out from the existing TestChecksums
. That test is more about how failed/valid checksums are handled, rather than ensuring a file can be resumed (tested elsewhere) or deal with edge-case server responses (this issue).
I'll adjust this and merge shortly! Thanks for the great work.
When merge?
Hey @setnicka, I went ahead and fixed the underlying issue here in 8835fd25e1df4ff402859a6ea8fd1002d9f1d7f7.
I apologize for not merging your request here. I tried quite a few ways to resolve conflicts with some more recent refactors and fix some outstanding edge cases. In the end, it made more sense just to fix the issues by hand where they now live. As a small consolation, I've attributed the fix to you. https://github.com/cavaliercoder/grab/commit/8835fd25e1df4ff402859a6ea8fd1002d9f1d7f7#diff-51565ad50d7426213c2f33579f6f0e71R712
Thanks for your understanding and excellent efforts here.
When there is no Content-Length header the default value is -1. So when there is -1 we cannot do check of the response length.