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.

changing parameter when post a form

Post Reply
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: changing parameter when post a form

Post by salvadordf »

Hi,

Use the TChromium.OnBeforeResourceLoad event to modify the request.
The PostInspectorBrowser demo has most of the code that you need.

These are the code comments for that event :

Code: Select all

  ///
  // Called on the IO thread before a resource request is loaded. The |request|
  // object may be modified. Return RV_CONTINUE to continue the request
  // immediately. Return RV_CONTINUE_ASYNC and call cef_request_tCallback::
  // cont() at a later time to continue or cancel the request asynchronously.
  // Return RV_CANCEL to cancel the request immediately.
  //
  ///
Also available here :
https://magpcss.org/ceforum/apidocs3/pr ... llback%3E)
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: changing parameter when post a form

Post by salvadordf »

lifeform wrote: Sun Apr 07, 2019 11:18 am based on https://magpcss.org/ceforum/apidocs3/pr ... stData%3E)

the link you gave to us, there is setPostData. but in the cef4delphi this method not found
i do not familiar about this. but can you confirm about this?

can i just set it as like this ?

Code: Select all

request.postData := editedPostData
Yes, you can do that.

ICefRequest.PostData is a property that calls ICefRequest.GetPostData and ICefRequest.SetPostData
https://github.com/salvadordf/CEF4Delph ... s.pas#L629
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: changing parameter when post a form

Post by salvadordf »

The ResponseFilterBrowser demo has an example about replacing HTTP headers in the request :
https://github.com/salvadordf/CEF4Delph ... r.pas#L419

The URLRequest demo shows how to create a POST element and how to add it to the request :
https://github.com/salvadordf/CEF4Delph ... t.pas#L197

This forum has a another example in Delphi :
http://www.programmersforum.ru/showpost ... stcount=25

Here is another example in the official CEF Wiki :
https://bitbucket.org/chromiumembedded/ ... m-requests

The PostInspectorBrowser demo shows how to read the POST elements :
https://github.com/salvadordf/CEF4Delph ... r.pas#L293

I'm not 100% sure if you need to create a POST element with TCefPostDataElementOwn.Create or TCefPostDataElementRef.New
Try both to see which one is released correctly and allows your app to close without errors.
Post Reply