Remove firing assertion when redirecting
authorachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 May 2016 21:46:06 +0000 (21:46 +0000)
committerachristensen@apple.com <achristensen@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 May 2016 21:46:06 +0000 (21:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155800
rdar://25299194

Reviewed by Sam Weinig.

* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:dataTask:willCacheResponse:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
(-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]):
With NSURLConnection, we stopped getting delegate callbacks once the delegate is destroyed, and everything was cancelled.
With NSURLSession we continue getting delegate callbacks because the session's delegate is not destroyed after each load.
As documented in NSURLSession.h: "In some cases, the task may signal other work before it acknowledges the cancelation."
In the cases where we cancel a load, delete the NetworkLoad and corresponding NetworkDataTask, we want to call all
completion handlers indicating that we really want to cancel instead of asserting.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200388 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cocoa/NetworkSessionCocoa.mm

index 53620e9..782e4c1 100644 (file)
@@ -1,3 +1,22 @@
+2016-05-03  Alex Christensen  <achristensen@webkit.org>
+
+        Remove firing assertion when redirecting
+        https://bugs.webkit.org/show_bug.cgi?id=155800
+        rdar://25299194
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/cocoa/NetworkSessionCocoa.mm:
+        (-[WKNetworkSessionDelegate URLSession:task:willPerformHTTPRedirection:newRequest:completionHandler:]):
+        (-[WKNetworkSessionDelegate URLSession:dataTask:willCacheResponse:completionHandler:]):
+        (-[WKNetworkSessionDelegate URLSession:task:didReceiveChallenge:completionHandler:]):
+        (-[WKNetworkSessionDelegate URLSession:task:didCompleteWithError:]):
+        With NSURLConnection, we stopped getting delegate callbacks once the delegate is destroyed, and everything was cancelled.
+        With NSURLSession we continue getting delegate callbacks because the session's delegate is not destroyed after each load.
+        As documented in NSURLSession.h: "In some cases, the task may signal other work before it acknowledges the cancelation."
+        In the cases where we cancel a load, delete the NetworkLoad and corresponding NetworkDataTask, we want to call all
+        completion handlers indicating that we really want to cancel instead of asserting.
+
 2016-05-02  Darin Adler  <darin@apple.com>
 
         Change IDL enumerations to be nested in their C++ class instead of at WebCore namespace level
index 103e44a..442cd7e 100644 (file)
@@ -121,10 +121,8 @@ static NSURLSessionAuthChallengeDisposition toNSURLSessionAuthChallengeDispositi
             completionHandlerCopy(request.nsURLRequest(WebCore::UpdateHTTPBody));
             Block_release(completionHandlerCopy);
         });
-    } else {
-        ASSERT_NOT_REACHED();
+    } else
         completionHandler(nil);
-    }
 }
 
 - (void)URLSession:(NSURLSession *)session dataTask:(NSURLSessionDataTask *)dataTask willCacheResponse:(NSCachedURLResponse *)proposedResponse completionHandler:(void (^)(NSCachedURLResponse * _Nullable cachedResponse))completionHandler
@@ -168,10 +166,8 @@ static NSURLSessionAuthChallengeDisposition toNSURLSessionAuthChallengeDispositi
             Block_release(completionHandlerCopy);
         };
         networkDataTask->didReceiveChallenge(challenge, challengeCompletionHandler);
-    } else {
-        ASSERT_NOT_REACHED();
-        completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
-    }
+    } else
+        completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, nil);
 }
 
 - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error