URL::createInputStream returns getTotalLength of 0

My application downloads files that are hosted on mediafire. For most of my users it works. But for a handful, the inputStream is returning with a getTotalLenth of 0. If I give them the links directly to download in their browser, it works fine.

What are some possible reasons the length would be 0? For example, is there header info I should be adding to ensure correct downloading? I’m currently creating the input stream with

url.createInputStream (false, nullptr, nullptr, String::empty, 10000);

On MAC or Windows?

They made some bug patches to the URL class on mac recently

Both. iPad too. JUCE 4.2

Can you check the develop branch? As Jake_Penn says, we fixed a few bugs in the URL::createInputStream code recently.

OK I updated to the latest develop branch, and the error remains. I checked the HTTP status code and these users are receiving a 401 error (unauthorized user). What’s strange is they can download these files in their browser. They’re only getting 401 through the JUCE inputStream. I’m checking with Mediafire of course, but I wonder is there anything in general I can add as an extraHeader that helps prevent 401 errors?

Hmmm can’t really say. You’ll need to debug a bit deeper and see which headers aren’t being sent correctly.

Any update on this??

After much back and forth with Mediafire, it started working correctly. I’m not sure exactly what was causing the disconnect between the two.

Ed recently pushed a fix for a (rather embarrassing) OS X bug that I proudly master minded :wink:. If you were sending post data then the content-length and content-type headers would not be modified correctly. See this post:

Every bug needs a master mind :slight_smile: