Needs work
Project:
Ubercart
Version:
7.x-3.x-dev
Component:
File downloads
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Jan 2010 at 09:45 UTC
Updated:
22 Jul 2018 at 18:52 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
tr commentedYes, I see what you mean. You are correct. Although $seek_end is calculated properly in the code, the loop ALWAYS tries to read until end of file, instead of stopping at $seek_end. Here's the part of the code that needs to be fixed:
Also note that set_time_limit() should be taken out of that loop - we only need to set it once, not keep setting it every 8kbytes. Any patch to this section of code should be checked against #193383: set_time_limit: Centralize calls and prevent warnings and errors, which changes the way set_time_limit() works.
I'm not currently set up to test partial content transfers, so I don't want to roll a patch I can't test. Bumping the priority up to normal.
Comment #2
tr commentedComment #3
torgospizzaWow, good find! I wonder if this issue would help some of our users who are getting incomplete downloads.
Subscribe! (I can test this if you want to post modified code.)
EDIT to add: Seems like we'll need to set a flag in the event of a partial content being downloaded (like a resumed download). If I start a new download and it reads the entire file, then $seek_end is the same as $size (filesize) and the $length ends up being 1, which results in a < 1KB-file being downloaded.
Comment #4
AlexisWilke commentedThe correct math is like this:
It is used in the header to define the total size of the transfer, and I would suggest you put it in a variable for the header and the loop below.
Thank you.
Alexis
Comment #5
torgospizzaThat's the math that I used, and I had several downloads fail. Can you post your modified code? Maybe I am doing something wrong. Thanks!
Comment #6
AlexisWilke commentedI did not modify my code... I don't even know how to generate a partial download to test...
Comment #7
AlexisWilke commentedHi guys,
According to this document:
http://tools.ietf.org/id/draft-ietf-http-range-retrieval-00.txt
There is another problem in the code which I think is important to mention.
The following will generate E_NOTICEs when $range does not include a dash because $seek_end cannot be set.
Then we do this:
As you can see, the end is determined only using $seek_end, which is wrong.
If $seek_start is not defined (i.e. "-300") then $seek_end must be set to $size - 1 and $start_end is then set to $size - 300.
At some point, I may write something to run curl() with a range (see CURLOPT_RANGE in curl_setopt()). But well... that code should maybe not say that it supports ranges for now... 8-)
Thank you.
Alexis Wilke
Comment #8
longwaveChanging component.
Comment #9
tr commentedComment #10
joelstein commentedI am encountering an "Undefined offset: 1" error on line 349 of uc_file.pages.inc, in _uc_file_download_transfer(), when a user is downloading a purchased file.
The offending line:
My error logger noted the "Range" header in this request was
bytes=4915200-. Note that there are no commas in that range header (which is a valid request).Since the $extra ranges variable is not used elsewhere in the code, I propose we simplify this line to the following which will gracefully handle situations where there is only a single range:
The attached patch accomplishes this for D7.
Comment #12
tr commentedThat doesn't fix #1 and #7 ... and we still need a test to demonstrate that any fix does the right thing ...