Refactored OSX/iOS streaming code and redirects

Hi Jules,

Looks like this commit ignores the handling of url redirects that was added a couple of years ago in this forum post.

I don’t have my own Mac at the moment, so I haven’t checked against the unit tests I provided, however it looks like you haven’t implemented the relevant delegate (relevant Apple doco).

I’m not using the URL class at present but I thought I’d mention it seeing as it appears to be a departure from the documented behaviour.

-Andrew

EDIT - looks like the attachments on the old post have disappeared, let me know if you want me to dig out the unit tests

Yes - if you have any tests that fail with the new code, we’d be very keen to try them! Couldn’t find any problems when I tested these changes, but since it’s using an entirely new API it’s quite likely that there are edge-cases we need to sort out.

Here you go. These worked fine a couple of years ago, but just running them on Windows again I can see some of the redirect tests are failing - didn’t have time to fire up Fiddler to figure out why though!

UrlUnitTests.h.txt (734 Bytes)

UrlUnitTests.cpp.txt (6.2 KB)

OK. I think this should be fixed on the latest develop tip. The unit tests all pass if I modify the expectedLocation on line 119 of UrlUnitTests.cpp from "/redirect/" to "/relative-redirect/". It seems as jigsaw.w3.org may have changed this. This would also explain why it doesn’t work on Windows.

OK, good pickup - it looks they introduced absolute redirect and had to differentiate it from relative.

However, on Windows 10 I’m still seeing failures at lines 93 and 107 (i.e. the basic 301 and 302 tests). Works OK if I visit in a browser on that machine, but the tests fail with the pageSource at lines 91 & 105 containing a few characters of junk.

I found two problems with the Win32 implementation:

  • At line 95 of juce_win32_Network.cpp - the code references dataHeaders[“Location”], however HttpQueryInfo is returning a key name of “location”

  • Maybe use ignoreCase=true when constructing the StringPairArray on line 56?

  • The formation of the new location at line 104 of juce_win32_Network.cpp strips out the existing server address so we end up with an invalid url to redirect to.

  • I think findEndOfScheme() at line 139 of juce_URL.cpp might have to be changed to:
    return url.substring (i, i+3) == "://" ? i + 1 : 0;

Polite bump…

This should be fixed on develop now.

Excellent - all good now on Windows 10.