News:

Support for jDownloads 3 has been ended
Since 17 August 2023 Joomla.org has discontinued support for Joomla 3.x. Therefore, we will no longer offer official support for our Joomla 3 jDownloads version 3.9.x from January 2024.
Please update your website to the latest Joomla version (Joomla 4 or Joomla 5) as soon as possible. Afterwards, please update jDownloads to the latest published version. The longer you delay, the more difficult the upgrade process for your website is likely to be.

Main Menu
Support-Forum

JDownloads 4.0.42 and Joomla 5.1.1 - browser error with use_resume true

Started by teflonmann, 28.06.2024 23:30:02

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

teflonmann

Joomla 5.1.1
JDownloads 4.0.42

I have uploaded several files of different types with JDownloads. I can download all files after that in the administration area without any problems. But in the frontend I receive this browser error: https://support.mozilla.org/gl/questions/1024256. The file download counter is increased by 10 after the unsuccessful download attempt. So it seems there are some retries.

So I went step by step through the code. In the file website/components/com_jdownloads/src/Controller/DownloadController.php there is the line 1074

$object->use_resume      = true;
that triggers later the insertion of the header

header("HTTP/1.0 206 Partial Content");
in the file website/components/com_jdownloads/src/Helper/JDownloader.php

After that line the system runs into the error.

If change the line in the controller file to

$object->use_resume      = false;
the file is downloaded correctly.

So what can I do now, because this is something that is hardcoded in your file and not configurable as far as I can see it?

Best regards,

Karsten
  •  

teflonmann

I dug a bit deeper into this.

In website/components/com_jdownloads/src/Helper/JDownloader.php the seek_range is received from $_SERVER['HTTP_RANGE']. And after that you set

$this->seek_end = intval($range[1]);

in line 124.

$this->seek_end can become bigger than the actual filesize, depending on what the server delivers. In my case $this->seek_end was then 5242879 (bytes) and the filesize was only 361735 (bytes).

This leads in line 171 to something like this

header("Content-Range: bytes 0-5242879/361735");
So the range is bigger than the actual files size.

So if you would (i.e. in the function
header() ) add a line like

if($seek_end >= $size) $seek_end = $size - 1;
it would solve the problem.

At least it did in my case.

Best regards,

Karsten
  •  

Arno

Hallo Karsten,
Thank you very much for your efforts.
I will test your suggestion and add it in a later release.
Unfortunately, it is too late for version 4.0.43 as I don't have the time to test this change at the moment.

However, I'm surprised because no one else has reported a problem like yours in all these years. So it must be related to other things. After all, there are tens of thousands of jDownloads installations.

By the way, as you have probably already seen, the JDownloads class is not mine. I just customised it slightly for my needs. But this script is also used by some other open source projects in the same way.

Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

teflonmann

Hi Arno,

thank you very much for your reply.

Your answer made me read and think again and I tested a little bit further.

Files above 5 MB can be downloaded properly. So it definitely is the HTTP_RANGE.

It seems the problem, that $_SERVER['HTTP_RANGE'] delivers a value, depends on the hosting provider. I put the line
var_dump($_SERVER['HTTP_RANGE']); in an empty php file an ran it on different servers and different hosting providers.

The provider DomainFactory returned "bytes=0-5242879". And you even find a setting for HTTP_RANGE in phpinfo(). I tested it with different accounts run by the provider. The same result everywhere.

IONOS and Strato for comparison return NULL, and HTTP_RANGE is not mentioned in phpinfo().

So i guess for some reason (performance?) DomainFactory decided to put 5 MB HTTP_RANGE it in their server configuration by default.

I do not know, when they started doing that. But the dependency on the hosting provider could be the reason only a few websites ran into this issue so far.

Best regards,

Karsten



  •