Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Resource Response

Post Reply
alpires2000
Posts: 52
Joined: Sat Dec 09, 2017 4:40 pm

Resource Response

Post 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;
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Resource Response

Post by dilfich »

You need to look at the examples, there is no simpler example(
demo - ResponseFilterBrowser
User avatar
salvadordf
Posts: 4575
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Resource Response

Post 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.
dilfich
Posts: 368
Joined: Thu Nov 30, 2017 1:17 am

Re: Resource Response

Post 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. ;)
Post Reply