diff --git a/modules/juce_core/native/juce_mac_Network.mm b/modules/juce_core/native/juce_mac_Network.mm index 64e9324efa..7389427244 100644 --- a/modules/juce_core/native/juce_mac_Network.mm +++ b/modules/juce_core/native/juce_mac_Network.mm @@ -391,6 +391,7 @@ public: connection (nil), data ([[NSMutableData data] retain]), headers (nil), + nsUrlErrorCode (0), statusCode (0), initialised (false), hasFailed (false), @@ -508,6 +509,7 @@ public: void didFailWithError (NSError* error) { DBG (nsStringToJuce ([error description])); ignoreUnused (error); + nsUrlErrorCode = [error code]; hasFailed = true; initialised = true; signalThreadShouldExit(); @@ -552,6 +554,7 @@ public: NSURLConnection* connection; NSMutableData* data; NSDictionary* headers; + NSInteger nsUrlErrorCode; int statusCode; bool initialised, hasFailed, hasFinished; const int numRedirectsToFollow; @@ -744,7 +747,20 @@ private: connection = new URLConnectionState (req, numRedirectsToFollow); if (! connection->start (progressCallback, progressCallbackContext)) + { + // 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 (connection->nsUrlErrorCode == NSURLErrorNetworkConnectionLost) + { + connection = new URLConnectionState (req, numRedirectsToFollow); + + if (connection->start (progressCallback, progressCallbackContext)) + return; + } + #endif + connection = nullptr; + } } }