Canceling an arbitrary request from LoadURL

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.

Canceling an arbitrary request from LoadURL

Postby Staxcelrom » Mon Jun 13, 2022 4:51 am

Hello,

Can you please tell me, it is possible to cancel all or an arbitrary request when I call a page load using LoadERL ?

I mean, for example- I called LoadURL("google.com") - and CEF started downloading all the resources associated with this page: .css, scripts, pictures - can any of these requests be canceled?
Staxcelrom
Expert
 
Posts: 206
Joined: Wed Jan 26, 2022 8:20 am

Re: Canceling an arbitrary request from LoadURL

Postby Staxcelrom » Mon Jun 13, 2022 5:55 am

OnBeforeResourceLoad
Staxcelrom
Expert
 
Posts: 206
Joined: Wed Jan 26, 2022 8:20 am

Re: Canceling an arbitrary request from LoadURL

Postby Staxcelrom » Mon Jun 13, 2022 6:17 am

Code: Select all
virtual CefResourceRequestHandler::ReturnValue OnBeforeResourceLoad(CefRefPtr<CefBrowser> browser, CefRefPtr<CefFrame> frame, CefRefPtr<CefRequest> request, CefRefPtr<CefCallback> callback) override
   {

      std::cout << "OnBeforeResourceLoad:" << (*request).GetURL() << std::endl;   //the correct URL request is displayed
      (*request).SetURL("www.someURL.com");
      std::cout << "OnBeforeResourceLoad:" << (*request).GetURL() << std::endl;   //After .setURL() - an empty string is displayed


      //return RV_CANCEL;
      return RV_CONTINUE;
   }


Can you please tell me - why after .setURL an empty string URL is displayed?
Staxcelrom
Expert
 
Posts: 206
Joined: Wed Jan 26, 2022 8:20 am

Re: Canceling an arbitrary request from LoadURL

Postby magreenblatt » Mon Jun 13, 2022 6:31 am

"www.someURL.com" is not a valid URL. It needs the protocol prefix.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Canceling an arbitrary request from LoadURL

Postby Staxcelrom » Mon Jun 13, 2022 7:37 am

Thank you! It works.
Staxcelrom
Expert
 
Posts: 206
Joined: Wed Jan 26, 2022 8:20 am


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 38 guests