JUCE_USE_CURL Send back the cookies sent by the server on redirects


#1

Hello,

Some sites require the client to send back the cookies sent by the server on redirects.

url in question:

fails

Setting curl_easy_setopt (curl, CURLOPT_COOKIEFILE, "") in juce_curl_Network.cpp WebInputStream::setOptions() fixes the issue.

https://curl.haxx.se/libcurl/c/CURLOPT_COOKIEFILE.html

Given an empty or non-existing file or by passing the empty string ("") to this option, you can enable the cookie engine without reading any initial cookies.


#2

Would this be a good thing to always enable?


#3

@fabien I’m not sure…

I think one solution would be to provide some way to set additional curl options in the juce::URL class if JUCE_USE_CURL is enabled.

An optional key/value pair(s) that can be set before URL::createInputStream() is called. URL::createInputStream() can check the JUCE_USE_CURL flag and grab the additional settings/options set? But this seems kinda messy and you’d probably need to also provide a way to set NSURLConnection options at that point to make sure each OS has this option.

Reading the docs suggests that passing an empty string with CURLOPT_COOKIEFILE “enables the cookie engine”. I’d compare this to all the other platforms(s).

NSURLConnection has cookies enabled and the cookie engine is based on the settings for the device. The url I posted earlier works on Mac OSX without any special options set in juce_mac_Network IMPL so I’d expect the same result on the Linux side.

I don’t have a windows box unfortunately to see if the url works there.


#4

OK I’ve added this to the develop branch. Thank you for reporting!