PxPlus User Forum

Twitter Twitter Twitter

Author Topic: How do I use headers/postData variants in *browser BeforeNavigate2 event?  (Read 650 times)

Jeff Wilder

  • Silver Member
  • ***
  • Posts: 30
    • View Profile
Does anyone have an example of how to use the headers or postData parameters in the *browser BeforeNavigate2() event? I'm declaring them as an object, but they never contain data and setting the values appears to be ignored.

I have created an object using this example and have no issues using the url variant in this manner. Are postData and headers usable objects?

Best Regards,
Jeff Wilder

Devon Austen

  • Staff
  • Diamond Member
  • *****
  • Posts: 277
  • Don’t Panic
    • View Profile
    • PVX Plus Technologies
Re: How do I use headers/postData variants in *browser BeforeNavigate2 event?
« Reply #1 on: November 12, 2018, 03:51:33 PM »
Hi Jeff,

Most of the arguments in the BeforeNavigate2 event are read only. The only affect you are allowed to have on the request itself is to allow it or cancel it. This is for security reasons I believe and works the same with Shell.Explorer.

If you want to modify the request you have to cancel it and do a new navigate with the modified URL, headers, or post data.

To read the values of headers and post data you do what it sounds like you are doing.

Code: [Select]
 ENTER pDisp,url,flags,targetFrameName,postData,headers,cancel

 DEF OBJECT targetFrameName
 DEF OBJECT headers
 DEF OBJECT postData

 MSGBOX "url="+url'val$+" flags="+STR(flags'val)+" targetFrameName="+targetFrameName'val$+" headers="+headers'val$+" postData="+postData'val$,"INFO"

Note that post data will only be present on a POST request and not a usual GET request. Headers also does not mean response headers as this is being called before the request is issued so there is no response. Headers are any additional headers set when the request is made. This is not something done often and if the navigation happened using our navigate method for *browser then we know for sure it didn't happen because our code does not set any request headers.
Software Developer for PVX Plus Technologies LTD.