Referer is not available in SetReferrerForRequest

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.

Referer is not available in SetReferrerForRequest

Postby Tom741 » Fri Apr 29, 2016 3:35 pm

Hello everyone,
I made some changes some time ago on the SetReferrerForRequest in resource_dispatcher_host_impl.cc cef version 39.
I wanted to upgrade to cef 49.

The code I used to set the referer was the following one:
Code: Select all
CefRefPtr<CefRequest> request(CefRequest::Create());
request->SetURL(myurl);
CefRequest::HeaderMap headerMap;
headerMap.insert(std::make_pair("Referer", "http://myref.com"));
request->SetHeaderMap(headerMap);
frame->LoadRequest(request);


That was working well with the 39 version.
However, now when I execute this code, the referer is null for the request I want to make (non https urls).
I added some debug line in cef and the passed const Referrer& referrer is empty.
Code: Select all
void SetReferrerForRequest(net::URLRequest* request, const Referrer& referrer) {


Do you maybe have an idea of why it changed and does not transmit the referer correctly ? Is it something with my code I need to update ?

Thanks,
Tom741
Techie
 
Posts: 31
Joined: Tue Aug 19, 2014 9:16 am

Re: Referer is not available in SetReferrerForRequest

Postby magreenblatt » Fri Apr 29, 2016 3:40 pm

There is now a CefRequest::SetReferrer() method.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Referer is not available in SetReferrerForRequest

Postby Tom741 » Sat Apr 30, 2016 6:10 am

Thanks for your reply, it works like a charm :).
It's much easier than the previous code ^^.
Tom741
Techie
 
Posts: 31
Joined: Tue Aug 19, 2014 9:16 am

Re: Referer is not available in SetReferrerForRequest

Postby wrightpt » Sat Jun 25, 2016 11:30 am

Can you let me know how you implemented the CefRequest::SetReferrer() method?

In my cef_request.h file, I have the virtual method:

virtual void SetReferrer(const CefString& referrer_url,
ReferrerPolicy policy) =0;


I am not sure where to go from there?

How do I override this or is that the proper term? Any input is appreciated
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: Referer is not available in SetReferrerForRequest

Postby wrightpt » Sat Jun 25, 2016 11:49 am

In cef_request.h:

Class used to represent a web request. The methods of this class may be
called on any thread.

Still working but getting closer:

Could I insert the below method into cefsimple_linux.cc under CefInitialize(main_args, settings, app.get(), NULL); ?

CefRequest::SetReferrer(https://www.google.com/?gws_rd=ssl,null)=0;


and then rebuild and remake?
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: Referer is not available in SetReferrerForRequest

Postby wrightpt » Sat Jun 25, 2016 12:30 pm

:shock: that definitely didn't compile :geek:
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am

Re: Referer is not available in SetReferrerForRequest

Postby wrightpt » Sat Jun 25, 2016 12:32 pm

home/c/Downloads/myproject2/cefsimple/cefsimple_linux.cc: In function ‘int main(int, char**)’:
/home/c/Downloads/myproject2/cefsimple/cefsimple_linux.cc:60:30: error: found ‘:’ in nested-name-specifier, expected ‘::’
CefRequest::SetReferrer(https://www.google.com/?gws_rd=ssl,null);
^
/home/c/Downloads/myproject2/cefsimple/cefsimple_linux.cc:60:25: error: ‘https’ has not been declared
CefRequest::SetReferrer(https://www.google.com/?gws_rd=ssl,null);
^
make[3]: *** [cefsimple/CMakeFiles/cefsimple.dir/cefsimple_linux.cc.o] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [cefsimple/CMakeFiles/cefsimple.dir/all] Error 2
make[1]: *** [cefsimple/CMakeFiles/cefsimple.dir/rule] Error 2
make: *** [cefsimple] Error 2
wrightpt
Expert
 
Posts: 151
Joined: Wed Jun 22, 2016 11:17 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], TakashiHSD and 27 guests