-
Notifications
You must be signed in to change notification settings - Fork 27
download fails when Content-Length is missing from headers #73
Comments
Anther great catch. Thanks for reporting the issues, @bcomnes 👍 I feel like hashing won't really work unless the file is actually downloaded completly (which we don't really want in this case). Hashing just the filename on the other hand is not enough for a in-depth comparision. I suggest we skip the "comparision" feature in this case and just re-download the file when there's no Content-Length set. What do you think? /cc @mattly |
The usefulness of the hashing comes from knowing if the remote file is different than what is present on the system... when that kind of information is important. For example, I really want to see if Yes there is a cost of downloading and hashing, comparing, downloading again to replace, then downloading and hashing again to double check, but for the case of small files, this cost is an ignorable cost to get at the 'did the file change or not' data point. It also shares a similar timing attack/bug vulnerability as the size check if the file happens to change on the server at that time, or incorrect headers are being sent across all 3 requests. One improvement would be to cache the request results once, perform the desired checks, attempt and recheck with a single request. For small files, you can assign the contents to a variable and this is pretty achievable. Here is an almost working prototype:
Third, its not clear to me if the server 404, or 500's, it looks like |
I don't remember what use case my initial stab at I think you both have good thoughts on the correct behaviors, and hash is definitely a better thing to check against than size. I'm going to deprecate the size option and remove it for 1.0, and add in a hash option. Thoughts on letting people specify the algorithm? |
Unless trivial to add, I would leave it to those who want to customize the algorithm to explore/implement that. I'm totally fine with a sane default. |
The following assertion fails:
because the http headers from this github request fails to return a
Content-length
Not really sure what the right way to handle this. Obviously, this strategy shouldn't be used in this kind of scenario. Maybe some kind of alternative hashing comparison could be used instead? I found this when dealing with the #72 bug.
The text was updated successfully, but these errors were encountered: