Thanks for the explaination, LGTM.

On Nov 19, 2015, at 09:08, Fu, Junwei 
<junwei...@intel.com<mailto:junwei...@intel.com>> wrote:

Hi Halton,

Those functions under Cookie[Sync]Manager are relative with request cookies not 
response cookies.

For example loading a website http://m.weibo.cn/
The response cookies are “Set-Cookie:M_WEIBOCN_PARAMS=uicode%3D20000174; 
expires=Tue, 10-Nov-2015 05:57:30 GMT; path=/; 
domain=.weibo.cn<http://weibo.cn/>”
The request cookie that can be get with CookieManager are 
“Cookie:_T_WM=485387a4681594220c4c1dc196db9daf;SUB=_2A257RfOdDeTxGeRI7FIX9S7Kwj2IHXVYyZ3VrDV6PUJbrdBeLVj4kW2W6ymGGmwjoGMa0cmIPY1wU0njBQ..;
 SUHB=0KAg8UHj9ce4fE; SSOLoginState=1447134157;”

Customer expect to get some properties like “expires”, “path” that aren’t 
stored in CookieManager.
The new delegate similar as the API 
getAllResponseHeader<http://www.w3.org/TR/XMLHttpRequest/#the-getallresponseheaders()-method>()
 in XMLHttpRequest. It returns all headers from the response, with the 
exception of those whose field name is Set-Cookie or Set-Cookie2.

The similar API in IOS platform is 
NSHTTPCookie<https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSHTTPCookie_Class/index.html#//apple_ref/occ/clm/NSHTTPCookie/cookiesWithResponseHeaderFields:forURL:>
class func cookiesWithResponseHeaderFields(_ headerFields: [String : 
String],forURL URL: NSURL) -> [NSHTTPCookie]

Thanks,
Junwei.
From: Huo, Halton
Sent: Wednesday, November 18, 2015 9:24 PM
To: Fu, Junwei
Cc: <crosswalk-dev@lists. crosswalk-project. org>
Subject: Re: [Crosswalk-dev] Intent to Implement get resources response headers

Junwei,

If we look at the Android web view cookie related API, there are bunch of 
functions under android.webkit.Cookie[Sync]Manager. It seems you intent to 
expose very raw level at resource loading phase, could you explain benefits on 
that?

Thanks,
Halton.
On Nov 18, 2015, at 16:12, Fu, Junwei 
<junwei...@intel.com<mailto:junwei...@intel.com>> wrote:

Description:
A requirement from Cloudbox that is an Android Web browser based on Crosswalk, 
It can be download from 
http://cloudbox.tinydust.cn<http://cloudbox.tinydust.cn/> . They have a cloud 
sync feature that allow users to sync their web apps, web app’s view states. 
Therefore the ability to access the cookies is essential. The 
XWalkCookieManager is useful for manipulating   cookies,  however Name and 
Value property of cookie is stored, they also need to get the Domain, Path, 
HttpOnly  properties and so on.
Another requirement is able to access the set-cookie header from an 
XMLHttpRequest, The refused message of “Refused to get unsafe header 
"set-cookie"” will be shown to block the ability.
The API getResponseHeader(header) is described in 
http://www.w3.org/TR/XMLHttpRequest/#the-getresponseheader()-method
        Returns the header field value from the response of which the field 
name matches header, unless the field name is Set-Cookie or Set-Cookie2.

So I intent to implement the new API in XWalkResourceClient to get resource 
response headers
public void onResourceResponseHeadersReceived(XWalkView view, String url, 
Map<String, String> headers) {
// Customer can get Set-Cookies as blow
String cookies = headers.get(“Set-Cookie”);
}

Related feature: XWALK-4267, XWALK-4643

Target release: Crosswalk-18

Implementation details:
Resources response header will be received in 
xwalk/runtime/browser/runtime_network_delegate.cc
int RuntimeNetworkDelegate::OnHeadersReceived(
    net::URLRequest* request,
    const net::CompletionCallback& callback,
    const net::HttpResponseHeaders* original_response_headers,
    scoped_refptr<net::HttpResponseHeaders>* override_response_headers,
GURL* allowed_unsafe_redirect_url) {
Io_thread_client->OnResourcesResponseHeaderReceived(original_response_headers)
   return net::OK;
}

Add a new function named OnResourcesResponseHeaderReceived in 
xwalkContentsIOThreadClient.h
Void OnResourcesResponseHeaderReceived (net::HttpResponseHeaders headers){
  //Get All of headers and store it in jStringArray
  //call Java function
}

Add new callback in XWalkResourceClient in order to be called by 
XWalkContentsClientBridge.java
public void onResourceResponseHeadersReceived(XWalkView view, String url, 
Map<String, String> headers) {
}

Thanks,
Junwei

_______________________________________________
Crosswalk-dev mailing list
Crosswalk-dev@lists.crosswalk-project.org<mailto:Crosswalk-dev@lists.crosswalk-project.org>
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-dev


_______________________________________________
Crosswalk-dev mailing list
Crosswalk-dev@lists.crosswalk-project.org
https://lists.crosswalk-project.org/mailman/listinfo/crosswalk-dev

Reply via email to