Page 1 of 1

Resource Response

Posted: Mon May 04, 2020 5:25 pm
by alpires2000
Hi Guys, my site call a .js file and return to me a JSON, exist some way to get this JSON in OnResourceResponse event. MiniBrowser can get the headers with this code, but i need get the JSON result, exist some way to do that?
Thanks from some help.

procedure TMiniBrowserFrm.Chromium1ResourceResponse(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse;
out Result: Boolean);
begin
Result := False;

if Chromium1.IsSameBrowser(browser) and (frame <> nil) and frame.IsMain and
frame.IsValid then
InspectResponse(response);
end;

procedure TMiniBrowserFrm.InspectResponse(const aResponse: ICefResponse);
var
TempHeaderMap: ICefStringMultimap;
i, j: Integer;
begin
if (aResponse <> nil) then
begin
FResponse.Clear;

TempHeaderMap := TCefStringMultimapOwn.Create;
aResponse.GetHeaderMap(TempHeaderMap);

i := 0;
j := TempHeaderMap.Size;

while (i < j) do
begin
FResponse.Add(TempHeaderMap.Key + '=' + TempHeaderMap.value);
inc(i);
end;
end;
end;

Re: Resource Response

Posted: Tue May 05, 2020 6:32 am
by dilfich
You need to look at the examples, there is no simpler example(
demo - ResponseFilterBrowser

Re: Resource Response

Posted: Tue May 05, 2020 9:39 am
by salvadordf
As Dilfich said, the ResponseFilterBrowser demo will always get the downloaded contents.

If you know the details of the request perhaps you can simulate it and use the URLRequest demo which is easier.

Re: Resource Response

Posted: Wed May 06, 2020 7:36 am
by dilfich
Ah not always, I for example did to only POST receive, can be perhaps and on filter of links do. The complexity is one, it is a construction, it is not always convenient for such a banal task.
If there was a procedure\function in the component, it would be convenient for sure, because it is obvious that this is in demand. ;)