1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-18 00:54:19 +00:00

Fix for HTTPS POST requests with keep-alive failing on OS X versions below 10.10

This commit is contained in:
ed 2017-01-05 16:54:00 +00:00
parent 5849710d85
commit 7120d7dfca

View file

@ -622,6 +622,7 @@ public:
connection (nil),
data ([[NSMutableData data] retain]),
headers (nil),
nsUrlErrorCode (0),
statusCode (0),
initialised (false),
hasFailed (false),
@ -745,6 +746,7 @@ public:
void didFailWithError (NSError* error)
{
DBG (nsStringToJuce ([error description])); ignoreUnused (error);
nsUrlErrorCode = [error code];
hasFailed = true;
initialised = true;
signalThreadShouldExit();
@ -789,6 +791,7 @@ public:
NSURLConnection* connection;
NSMutableData* data;
NSDictionary* headers;
NSInteger nsUrlErrorCode;
int statusCode;
bool initialised, hasFailed, hasFinished;
const int numRedirectsToFollow;
@ -878,16 +881,24 @@ public:
connection = nullptr;
}
bool connect (WebInputStream::Listener* webInputListener)
bool connect (WebInputStream::Listener* webInputListener, int attemptNumber = 0)
{
createConnection ();
createConnection();
if (! connection->start (owner, webInputListener))
{
// Workaround for deployment targets below 10.10 where HTTPS POST requests with keep-alive fail with the NSURLErrorNetworkConnectionLost error code.
#if ! (JUCE_IOS || (defined (__MAC_OS_X_VERSION_MIN_REQUIRED) && defined (__MAC_10_10) && __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_10))
if (attemptNumber == 0 && connection->nsUrlErrorCode == NSURLErrorNetworkConnectionLost)
{
connection = nullptr;
return connect (webInputListener, ++attemptNumber);
}
#endif
connection = nullptr;
return false;
}
if (connection != nullptr && connection->headers != nil)
{
statusCode = connection->statusCode;