<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>188691</bug_id>
          
          <creation_ts>2018-08-16 21:23:15 -0700</creation_ts>
          <short_desc>REGRESSION (iOS 12): WKWebView cookies are empty in responseHeaders</short_desc>
          <delta_ts>2019-08-13 08:18:04 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKit2</component>
          <version>WebKit Local Build</version>
          <rep_platform>iPhone / iPad</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P1</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Raghavendra">raghavendra.l</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>achristensen</cc>
    
    <cc>ap</cc>
    
    <cc>bchenindeed</cc>
    
    <cc>beidson</cc>
    
    <cc>cdumez</cc>
    
    <cc>dc2910</cc>
    
    <cc>elitree</cc>
    
    <cc>ggaren</cc>
    
    <cc>jp5316</cc>
    
    <cc>loreboa84</cc>
    
    <cc>niklasmerz</cc>
    
    <cc>sihui_liu</cc>
    
    <cc>tim.pruessing</cc>
    
    <cc>webkit-bug-importer</cc>
    
    <cc>youennf</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1451023</commentid>
    <comment_count>0</comment_count>
    <who name="Raghavendra">raghavendra.l</who>
    <bug_when>2018-08-16 21:23:15 -0700</bug_when>
    <thetext>in IOS11 cookies can be read in decidePolicyForNavigationResponse as specified below.

- (void)webView:(WKWebView *)webView decidePolicyForNavigationResponse:(WKNavigationResponse *)navigationResponse decisionHandler:(void (^)(WKNavigationResponsePolicy))decisionHandler
{
 
NSDictionary *allFields = [(NSHTTPURLResponse*)response allHeaderFields];
NSArray *cookies = [NSHTTPCookie cookiesWithResponseHeaderFields:allFields forURL:[NSURL URLWithString:@&quot;&quot;]];
//in iOS11 all cookies array contain all cookies
//in IOS12 beta, cookies are empty.

}

Since WkWebView default cookie APIs are still not providing correct cookie information, it is very important to rely cookie information from WkWebView Delegate Callbacks.
In iOS 12 Beta 8, we are seeing the Cookies are empty. 
To confirm again, Cookie information can be read in iOS11.2.x+ WkWebView.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1451285</commentid>
    <comment_count>1</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2018-08-17 16:56:49 -0700</bug_when>
    <thetext>&lt;rdar://problem/43445256&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1451310</commentid>
    <comment_count>2</comment_count>
    <who name="Chris Dumez">cdumez</who>
    <bug_when>2018-08-17 18:03:33 -0700</bug_when>
    <thetext>Yes, this was an intentional behavior change.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1451311</commentid>
    <comment_count>3</comment_count>
    <who name="John Polston">jp5316</who>
    <bug_when>2018-08-17 18:08:40 -0700</bug_when>
    <thetext>Chris, is this intentional just for this build (Beta 8) or is this permanent and if so, is there a documented work-around or alternate method?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1451335</commentid>
    <comment_count>4</comment_count>
    <who name="Geoffrey Garen">ggaren</who>
    <bug_when>2018-08-17 20:34:12 -0700</bug_when>
    <thetext>&gt; Since WkWebView default cookie APIs are still not providing correct cookie
&gt; information

Can you clarify this problem?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1451390</commentid>
    <comment_count>5</comment_count>
    <who name="Raghavendra">raghavendra.l</who>
    <bug_when>2018-08-18 09:28:38 -0700</bug_when>
    <thetext>WKHTTPCookieStore has below API to fetch cookies.
- (void)getAllCookies:(void (^)(NSArray&lt;NSHTTPCookie *&gt; *))completionHandler;

But the API does not work consistently. Sometimes it gets the cookies and sometimes it provides the old cookies even though new Cookies or updated cookies are available.
This API has not worked in iOS11 too and it&apos;s inconsistent behavior is continues to be there in iOS12 beta too.


What is the reason for not allowing apps to read cookies from headers? Each application is different, framework/platform should be rich to provide the required details through appropriate APIs. By fencing/curtailing capabilities do not add any value to users through development eco system.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1452963</commentid>
    <comment_count>6</comment_count>
    <who name="Sihui Liu">sihui_liu</who>
    <bug_when>2018-08-22 22:35:23 -0700</bug_when>
    <thetext>(In reply to Raghavendra from comment #5)
&gt; WKHTTPCookieStore has below API to fetch cookies.
&gt; - (void)getAllCookies:(void (^)(NSArray&lt;NSHTTPCookie *&gt; *))completionHandler;
&gt; 
&gt; But the API does not work consistently. Sometimes it gets the cookies and
&gt; sometimes it provides the old cookies even though new Cookies or updated
&gt; cookies are available.
&gt; This API has not worked in iOS11 too and it&apos;s inconsistent behavior is
&gt; continues to be there in iOS12 beta too.
&gt; 
&gt; 
&gt; What is the reason for not allowing apps to read cookies from headers? Each
&gt; application is different, framework/platform should be rich to provide the
&gt; required details through appropriate APIs. By fencing/curtailing
&gt; capabilities do not add any value to users through development eco system.

Could you provide a test case where getAllCookies of WKHTTPCookieStore returns wrong cookies?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1453595</commentid>
    <comment_count>7</comment_count>
    <who name="bchenindeed">bchenindeed</who>
    <bug_when>2018-08-24 15:24:21 -0700</bug_when>
    <thetext>(In reply to John Polston from comment #3)
&gt; Chris, is this intentional just for this build (Beta 8) or is this permanent
&gt; and if so, is there a documented work-around or alternate method?

Yes.  Would like an update on this as well.  I&apos;m guessing this might be a fairly impactful decision for a number of developers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1454848</commentid>
    <comment_count>8</comment_count>
    <who name="Sihui Liu">sihui_liu</who>
    <bug_when>2018-08-29 11:04:48 -0700</bug_when>
    <thetext>HTTP headers in response are filtered for security. https://bugs.webkit.org/show_bug.cgi?id=184310

The intended way to retrieve cookies now is via WKHTTPCookieStore API. For cases it doesn&apos;t work as expected, please file a bug so we could improve it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1454905</commentid>
    <comment_count>9</comment_count>
    <who name="bchenindeed">bchenindeed</who>
    <bug_when>2018-08-29 13:22:43 -0700</bug_when>
    <thetext>Done: https://bugs.webkit.org/show_bug.cgi?id=188995</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1471201</commentid>
    <comment_count>10</comment_count>
    <who name="Lorenzo Boaro">loreboa84</who>
    <bug_when>2018-10-22 06:18:01 -0700</bug_when>
    <thetext>This change has a deep impact.

Currently WKWebView does not offer an API to deal with third part cookies as per https://bugs.webkit.org/show_bug.cgi?id=140205.

WKHTTPCookieStore does not have an API in order to deal with this scenario.

Any workaround in the short term?

Thanks,
Lorenzo</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>