No "set-cookie" header in response via CefURLRequestClient

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

No "set-cookie" header in response via CefURLRequestClient

Postby jkum » Tue Oct 22, 2019 3:59 am

OS: Windows
Cef-Branch: 3865

I am facing some challenges migrating to the latest 77 build of cef.(from 72). So in my implementation I was using CefURLRequestClient\CefURLRequest to pass an custom handler to GetResourceHandler.
The response that I get now with cef-77 is omitting the set-cookie header it seems. Is this intended or there are some specific changes that needs to be taken care of now.
I went through the details provided in "Support for NetworkService" PR but didn't find any details regarding this functionality.

I have added the GetCookieAccessFilter, CanSendCookie, and CanSaveCookie functions to client handler. Also tried with/without "UR_FLAG_ALLOW_STORED_CREDENTIALS' flag.

Any input would be helpful.
Thanks.
jkum
Techie
 
Posts: 15
Joined: Thu Mar 01, 2018 3:50 am

Re: No "set-cookie" header in response via CefURLRequestClie

Postby magreenblatt » Tue Oct 22, 2019 5:09 am

You need to set UR_FLAG_ALLOW_STORED_CREDENTIALS on the CefRequest passed to CefURLRequest::Create. The cookie will then be available via the associated CefCookieManager.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: No "set-cookie" header in response via CefURLRequestClie

Postby jkum » Wed Oct 30, 2019 6:22 am

Hi Marshall

I think you got the question wrong, what I meant was that in the response returned by CefURLRequest::Create() function all other headers are present but the "Set-Cookie" header is missing, though the cookies are applied on subsequent requests using the flag you mentioned.

Tried to debug the cef code to see if the root cause can be found.
Reached til the proxy_url_loader_factory.cc file, and even in the InterceptedRequest::OnHeadersReceived() function the Set-Cookie header is missing.

Do you think this is an issue with chromium ?

I tried to debug further and last point i could reach was the TrustedHeaderClientStubDispatch::AcceptWithResponder() function in network_context.mojom.cc file and looks like the message that is passed itself has the set-cookie header missing, it would be great if you could point me to the code where the message(response) is being formed and dispatched.

Thanks for your help.
jkum
Techie
 
Posts: 15
Joined: Thu Mar 01, 2018 3:50 am

Re: No "set-cookie" header in response via CefURLRequestClie

Postby magreenblatt » Wed Oct 30, 2019 9:46 am

The Set-Cookie header is handled internally. You can retrieve the cookie value from CefCookieManager.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: No "set-cookie" header in response via CefURLRequestClie

Postby jkum » Mon Nov 11, 2019 8:02 am

Hey Marshall

As suggested by you now I am trying to use CefCookieManager::GetGlobalManager(NULL)->VisitUrlCookies() to retrive the cookie values.
Getting into a few issues with this approach as well.
I am calling VisitUrlCookies function from within CefResourceHandler::GetResponseHeaders() which is called on IO thread, whereas the CefCookieManager::VisitUrlCookies function and the CefCookieVisitor::Visit are called on UI thread.

Thus I am facing an synchronization issue. I tried to use CefWaitableEvent as used in cookie tests , but looks like the wait() function cant be used on IO/UI thread.
Using std::condition_variable present another challenge, it looks like the VisitUrlCookies task is posted on UI thread but the CefCookieVisitor::Visit() function is not called until the control leaves CefResourceHandler::GetResponseHeaders() , placed a long wait after the VisitUrlCookies call but didnt get the control inside CefCookieVisitor::Visit() thus the cookie data is not available at next step.

Any suggestions as to how synchronization can be achieved.

Thanks
jkum
Techie
 
Posts: 15
Joined: Thu Mar 01, 2018 3:50 am

Re: No "set-cookie" header in response via CefURLRequestClie

Postby magreenblatt » Mon Nov 11, 2019 11:00 am

You should delay execution of the ProcessRequest callback until after you have asynchronously retrieved all necessary information.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: No "set-cookie" header in response via CefURLRequestClie

Postby alienhe » Fri Dec 29, 2023 3:38 am

i met this question too,can anybody gives a help~
alienhe
Newbie
 
Posts: 1
Joined: Fri Dec 29, 2023 3:36 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 49 guests