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.

How do I can parse request.PostData?

Post Reply
User avatar
RedOctober
Posts: 8
Joined: Sat Jul 07, 2018 12:59 pm
Location: Montenegro
Contact:

How do I can parse request.PostData?

Post by RedOctober »

Hello,

is there any way to parse request.PostData in onBeforeResourceLoad as string? For example, to get something like this:

Code: Select all

aaa=111&bbb=222&ccc=333
User avatar
RedOctober
Posts: 8
Joined: Sat Jul 07, 2018 12:59 pm
Location: Montenegro
Contact:

Re: How do I can parse request.PostData?

Post by RedOctober »

I found this solution - hope it will help someone ;)

Code: Select all

procedure Chromium1GetResourceHandler(Sender: TObject; const browser: ICefBrowser;
const frame: ICefFrame; const request: ICefRequest; out Result: ICefResourceHandler);
var
AElements:ICefPostDataElement;
AStr:AnsiString;
begin
if Assigned(request.PostData) then
begin
AElements := ICefPostDataElement(request.PostData.GetElements(1)[0]);
if (AElements.GetType = TCefPostDataElementType.PDE_TYPE_BYTES)
or (AElements.GetType = TCefPostDataElementType.PDE_TYPE_FILE) then
begin
SetLength(AStr,AElements.GetBytesCount);
AElements.GetBytes(AElements.GetBytesCount,PChar(AStr));
end;
end;
end;
User avatar
salvadordf
Posts: 4040
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How do I can parse request.PostData?

Post by salvadordf »

I'm glad you found the solution. :D

I was going to suggest the TForm1.HandlePostData procedure in the PostInspectorBrowser demo.

There's even a function to get the "key" and "value" pairs in the new uCEFOAuth2Helper.pas CEF4Delphi unit called ParseCodeRequestResponse.
Post Reply