Page 1 of 1
Replacing redirect URL
Posted: Thu May 23, 2024 9:16 am
by Vaytl
I'm trying to change the redirect. But it doesn't work.
Code: Select all
procedure TMiniBrowserFrm.Chromium1ResourceRedirect(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse;
var newUrl: ustring);
begin
if newUrl = 'https://old-url.com/redirect' then
newUrl := 'https://new-url.com';
end;
Re: Replacing redirect URL
Posted: Thu May 23, 2024 1:31 pm
by salvadordf
Hi,
Try using TChromium.OnBeforeResourceLoad to redirect a request.
Code: Select all
/// Called on the IO thread before a resource request is loaded. The |browser|
/// and |frame| values represent the source of the request, and may be NULL
/// for requests originating from service workers or ICefUrlRequest. To
/// redirect or change the resource load optionally modify |request|.
/// Modification of the request URL will be treated as a redirect. Return
/// RV_CONTINUE to continue the request immediately. Return RV_CONTINUE_ASYNC
/// and call ICefCallback functions at a later time to continue or cancel
/// the request asynchronously. Return RV_CANCEL to cancel the request
/// immediately.
Re: Replacing redirect URL
Posted: Thu May 23, 2024 5:16 pm
by Vaytl
Excellent, thank you!
Re: Replacing redirect URL
Posted: Tue May 28, 2024 11:16 am
by Vaytl
Please tell me why the redirect is not displayed in Chromium1ResourceRedirect, for example, "https://google.com/" redirect to "https://www.google.com/"?
Also in Chromium1GetResourceResponseFilter there is no 'Location' in response header?
Re: Replacing redirect URL
Posted: Tue May 28, 2024 2:48 pm
by salvadordf
Please, understand that CEF4Delphi is only a CEF wrapper and it can only give you access to all the information, methods, events, etc. allowed by CEF and Chromium.
In this case, the available headers on some events are decided by Chromium. I'm not sure if the redirect information is provided by CEF or Chromium.
Re: Replacing redirect URL
Posted: Tue May 28, 2024 4:05 pm
by Vaytl
Thank you for your assistance, Salvador.