URL::createInputStream returns getTotalLength of 0


#1

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);


#2

On MAC or Windows?

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


#3

Both. iPad too. JUCE 4.2


#4

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


#5

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?


#6

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


#7

Any update on this??


#8

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


#9

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:


#10

Every bug needs a master mind :slight_smile: