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.
View Request.PostData to str
View Request.PostData to str
Hi!
Please, show an example of how to do it?
Please, show an example of how to do it?
You do not have the required permissions to view the files attached to this post.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: View Request.PostData to str
Hi,
Take a look at the PostDataInspector demo.
Take a look at the PostDataInspector demo.
Re: View Request.PostData to str
There not showing PostData
These data are how to see?
These data are how to see?
You do not have the required permissions to view the files attached to this post.
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: View Request.PostData to str
Hi,
The OnBeforeNavigation is handled in the GlobalCEFApp_OnBeforeNavigation procedure, inside the DPR file.
In that procedure you have the request with all the information you asked.
request.PostData.GetElements will give you a list of ICefPostDataElement interfaces which have the posted data.
Then you can use ICefPostDataElement.GetBytesCount and ICefPostDataElement.GetBytes to get the information from that element.
The OnBeforeNavigation is handled in the GlobalCEFApp_OnBeforeNavigation procedure, inside the DPR file.
In that procedure you have the request with all the information you asked.
request.PostData.GetElements will give you a list of ICefPostDataElement interfaces which have the posted data.
Then you can use ICefPostDataElement.GetBytesCount and ICefPostDataElement.GetBytes to get the information from that element.
Re: View Request.PostData to str
Correctly?
But as for the string, I just don't understand..?
Code: Select all
if (request = nil) then
TempString := 'no request'
else
if (request.postdata = nil) then
TempString := 'no postdata'
else begin
Plist := Request.postData.GetElements(Request.postData.GetCount);
for i:=0 to Plist.Count-1 do
PElement:= Plist[i] as ICefPostDataElement;
TempString := 'postdata elements : ' + inttostr(PElement.GetBytesCount);
end;
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: View Request.PostData to str
Use the TStringStream class with the TStringStream.WriteBuffer function.
I haven't tested this but you might have to set the right encoding when you create the TStringStream instance.
I haven't tested this but you might have to set the right encoding when you create the TStringStream instance.
Re: View Request.PostData to str
Hi dilfich,dilfich wrote: ↑Sun Dec 03, 2017 8:10 pm Correctly?But as for the string, I just don't understand..?Code: Select all
if (request = nil) then TempString := 'no request' else if (request.postdata = nil) then TempString := 'no postdata' else begin Plist := Request.postData.GetElements(Request.postData.GetCount); for i:=0 to Plist.Count-1 do PElement:= Plist[i] as ICefPostDataElement; TempString := 'postdata elements : ' + inttostr(PElement.GetBytesCount); end;
Did you managed to get the POST as strings ?
EDIT:
I've found the solution
Code: Select all
SetLength(myAnsiString, PElement.GetBytesCount);
PElement.GetBytes(PElement.GetBytesCount, PAnsiChar(myAnsiString));
Re: View Request.PostData to str
Your design from the examples works fine! But how to see the response of POST request?TShowPostDataInfo(const aPostData : ICefPostData);
Chromium1BeforeResourceLoad....
if request.Method = 'POST' then TShowPostDataInfo(Request.PostData);
Re: View Request.PostData to str
To clarify, the POST request was made through JS or JONS of the page itself and in the browser itself through RetrieveText or RetrieveHTML response can not be obtained.
For example in procedure Chromium1ResourceResponse perhaps can be as the get the answer?
For example in procedure Chromium1ResourceResponse perhaps can be as the get the answer?
- salvadordf
- Posts: 4057
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: View Request.PostData to str
Try the TChromium.OnResourceResponse event.
The MiniBrowser has the code that reads the response in TMiniBrowserFrm.Chromium1ResourceResponse which calls TMiniBrowserFrm.InspectResponse
I'm not 100% sure it will work with requests made from JavaScript.
The MiniBrowser has the code that reads the response in TMiniBrowserFrm.Chromium1ResourceResponse which calls TMiniBrowserFrm.InspectResponse
I'm not 100% sure it will work with requests made from JavaScript.