From ffcef907b309ccbde2f89702b5d6b72a6f1b2790 Mon Sep 17 00:00:00 2001 From: Andrew Hankinson Date: Sat, 21 Jun 2014 20:36:12 -0400 Subject: [PATCH] Fixed: CPURLConnection now accepts withCredentials From the original PR: CPURLConnection was modified to reduce the withCredentials flag to a file-scope member. This has been done to facilitate use of withCredentials when a developer cannot modify the CPURLConnection manually (e.g. https://github.com/wireload/Ratatosk/blob/master/WLRemoteLink.j, line 466). Refs #1296, #2138 --- Foundation/CPURLConnection.j | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Foundation/CPURLConnection.j b/Foundation/CPURLConnection.j index b520cf9fd..0349947c1 100644 --- a/Foundation/CPURLConnection.j +++ b/Foundation/CPURLConnection.j @@ -27,6 +27,7 @@ @import "CPURLResponse.j" var CPURLConnectionDelegate = nil; +var withCredentials = NO; /*! @class CPURLConnection @@ -87,6 +88,21 @@ var CPURLConnectionDelegate = nil; CPURLConnectionDelegate = delegate; } +/* + Sets a flag to designate whether async XMLHTTPRequests should allow credentials to be sent or not. + This only works with async calls. + @param willSendWithCredentials flag to let XMLHTTPRequests to use withCredentials +*/ ++ (void)setWithCredentials:(BOOL)willSendWithCredentials +{ + withCredentials = willSendWithCredentials; +} + ++ (BOOL)withCredentials +{ + return withCredentials; +} + /* Sends a request for the data from a URL. This is the easiest way to obtain data from a URL. @param aRequest contains the URL to request the data from @@ -189,6 +205,8 @@ var CPURLConnectionDelegate = nil; { _isCanceled = NO; + _HTTPRequest.setWithCredentials(withCredentials); + try { _HTTPRequest.open([_request HTTPMethod], [[_request URL] absoluteString], YES);