Browse Source

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

tags/2021-05-28
ed 9 years ago
parent
commit
7120d7dfca
1 changed files with 14 additions and 3 deletions
  1. +14
    -3
      modules/juce_core/native/juce_mac_Network.mm

+ 14
- 3
modules/juce_core/native/juce_mac_Network.mm 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;


Loading…
Cancel
Save