luowenxing/PWKWebView

Why is it necessary to manually construct the cookie header for outgoing responses?

Opened this issue · 0 comments

From my understanding of the code, when load(_ request: URLRequest) is called on the webview, we completely take over the loading process. Instead of asking WebKit to send out the URL request, the webview will ask a URLSessionTask to do it.

However, URLSessionTask can already send the correct cookies from NSHTTPCookieStorage when it's loading a URL request, without constructing the custom Cookie header in the mutable URL request. Is the syncCookies(_ req: URLRequest) call before triggering the URLSessionTask load actually useful then? I understand it might make sense to do this if there's any error (this line) but I have a feeling it might be OK to just let the URLSessionTask handle cookies during the manual request process.