Page 1 of 1

Get body Request.

Posted: Fri Oct 04, 2019 5:36 pm
by Djota
Hello,
how do I get the body of a request?
Inside this boby is a JSON that you need to search when loading a site.

procedure TForm1.Chromium1ResourceResponse(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame;
const request: ICefRequest; const response: ICefResponse;
out Result: Boolean);
var
PostData: ICefPostData;
i: integer;
begin
PostData := request.PostData;
if (PostData <> nil) then
begin
for i := 0 to PostData.GetCount -1 do
begin

end;
end;
end;


I don't know how to convert ICefPostData content to a string.

Thanks

Re: Get body Request.

Posted: Fri Oct 04, 2019 7:19 pm
by salvadordf
If your application makes the request then you can use a TCEFUrlRequestClientComponent component. The URLRequest demo shows how to create the request and get all the data.

If you need to intercept the results of a request then you can use the code in the ResponseFilterBrowser demo.

Re: Get body Request.

Posted: Mon Oct 07, 2019 11:36 am
by Djota
I couldn't understand the ResponserFilterBrowser example.
What I need is, the page I'm accessing when I click a print button, he makes a request, and in this request he passes a JSON on Post, so I need to get this POST to get this JSON ...

Re: Get body Request.

Posted: Mon Oct 07, 2019 3:59 pm
by salvadordf
Sorry, I misunderstood.

Then you need to use the PostInspectorBrowser demo. That demo inspects the POST data in all requests using the TChromium.OnBeforeResourceLoad event.