1

Trying to move from TWebBrowser to TEdgeBrowser.

In a particular use case when a website is redirecting I am capturing the redirect and am also capturing the HTTP POST data and the XML contained therein and making use of the PostData variable in the BeforeNavigate2 method.

In the old TWebBrowser component the BeforeNavigate2 method contains a PostData variable which is of OleVariant:

BeforeNavigate2(ASender: TObject; const pDisp: IDispatch; const URL, Flags, TargetFrameName, PostData, Headers: OleVariant; var Cancel: WordBool);

Trying to move to TEdgeBrowser in Delphi 11 and this PostData is not part of the new NavigationStarting event:

NavigationStarting(Sender: TCustomEdgeBrowser; Args: TNavigationStartingEventArgs);

Also similar arguments when using the WVBrowser wrapper for the WebView2 browser in Delphi 10:

NavigationStarting(Sender: TObject; const aWebView: ICoreWebView2; const aArgs: ICoreWebView2NavigationStartingEventArgs);

Ultimately I am looking for the POST data and cannot find it in the args or in any method.

Does it exist anywhere, and if so, where?

Cheers! TJ

TJ Asher
  • 737
  • 9
  • 27
  • There's no real similar method. The way to go is probably using the WebResourceRequested event. This blog post (not about Delphi, though) could be useful: https://weblog.west-wind.com/posts/2021/Aug/18/Using-the-WebView-control-to-capture-Request-Content – Matthias B Mar 31 '23 at 21:06
  • TWebBrowser and TEdgeBrowser don't support the necessary interfaces to do that. I answered a similar question here: https://stackoverflow.com/a/72865336/7752510 – Salvador Díaz Fau Apr 01 '23 at 15:29
  • @SalvadorDíazFau - I have made use of that excellent answer to send data TO the server but am looking to handle the response FROM the server. – TJ Asher Apr 03 '23 at 12:36
  • @MatthiasB - I will check that post out. – TJ Asher Apr 03 '23 at 12:36
  • @TJAsher Check the MiniBrowser demo in the WebView4Delpi project. https://github.com/salvadordf/WebView4Delphi/blob/main/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas Call TWVBrowser.AddWebResourceRequestedFilter, implement the TWVBrowser.OnWebResourceResponseReceived. You can read the response headers in that event and also call TCoreWebView2WebResourceResponseView.GetContent. Then you'll receive the response contents in TWVBrowser.OnWebResourceResponseViewGetContentCompleted. – Salvador Díaz Fau Apr 03 '23 at 13:47

0 Answers0