WebBrowser (open)
Utility class to communicate with HTTP servers
Syntax
LOADLIB "wh::internet/webbrowser.whlib";
OBJECTTYPE WebBrowser
Constructor
- MACRO NEW()
Constructs a new WebBrowser object
Variables
- BOOLEAN debug
log everything we do
- FUNCTION PTR OnError
Called when an error occurs. Signature: MACRO onerror(STRING lastmessage)
- FUNCTION PTR onrequest
Called before every request, can be used to modify the request Signature: FUNCTION onrequest(RECORD data)
- url URI
- method HTTP method
- headers List of headers
- body Body Return: modified record
- BOOLEAN printnavigation
print navigation actions. testfw uses this so we don't need to print every flaky navigation action
- MACRO PTR ARRAY pvt_traffichooks
List of macro ptrs that will be called for every request Signature: MACRO hook(BOOLEAN beforerequest, STRING method, STRING url, INTEGER transactionid, RECORD data);
- STRING ARRAY ssloptions
List of SSL options to use
- "SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION": Allow legacy insecure renegotiation between OpenSSL and unpatched clients or servers.
Properties
- PROPERTY autofollow
(boolean) Autofollow redirects. Default: TRUE
- PROPERTY autofollow_statuses
HTTP status codes that will be auto-followed. Default: 301, 302, 303 and 307
- PROPERTY content
Content of current page
- PROPERTY contenttype
Content type of current page
- PROPERTY document
Content of the document parsed as XML document (or from an HTML doc, when contenttype = text/html)
- PROPERTY hash
(string) Hash of current URL (when redirected with hash)
- PROPERTY lasterror
Last error
- PROPERTY mimetype
(string) Mime type of current page
- PROPERTY onauth
Handler called to retrieve authentication information Signature: RECORD FUNCTION authhandler(STRING realm, STRINGauthurl) Return a record with cells
username
andpassword
. - PROPERTY onproxyauth
Handler called to retrieve proxy authentication information Signature: RECORD FUNCTION authhandler(STRING realm, STRINGauthurl) Return a record with cells
username
andpassword
. - PROPERTY peercertificatechain
(string) PEM-encoded certificate chain of the peer
- PROPERTY persistentconnections
(boolean) Whether connections are persistent, default: TRUE
- PROPERTY responseheaders
(record array) Response headers
- PROPERTY timeout
(string) Set webserver timeout in milliseconds
- PROPERTY url
(string) Current URL
- PROPERTY useragent
(string) Override user agent
Functions
- ASYNC FUNCTION AsyncGotoWebPage(STRING url, RECORD options)
Open a URL in the webbrowser (GET request), runs asynchronously
- ASYNC FUNCTION AsyncInvokeJSONRPC(STRING url, STRING methodname, VARIANT ARRAY args2, RECORD options)
Asynchronously executes a JSON RPC call
- ASYNC FUNCTION AsyncPostWebPage(STRING url, RECORD ARRAY variables, STRING enctype, STRING charset)
Asynchronously submits a POST request
- OBJECT FUNCTION AsyncPostWebPageBlob(STRING url, RECORD ARRAY headers, BLOB request_body)
Asynchronously post a URL in a webbrowser
- ASYNC FUNCTION AsyncSendRawRequest(STRING method, STRING url, RECORD ARRAY headers, BLOB request_body, RECORD options)
Sends a asynchronous request. Make sure not to run another request simulateously on this browser object.
- VARIANT FUNCTION CallJSONRPC(STRING url, STRING methodname, VARIANT ARRAY arguments)
Executes a JSON RPC call
- VARIANT FUNCTION CallJSONRPC20(STRING url, STRING methodname, VARIANT argument)
Executes a JSON RPC call, with the JSONRPC 2.0 protocol
- MACRO Close()
Closes any persistent connections and releases all resources
- MACRO CloseCurrentConnection()
Closes the current persistent connection
- MACRO DeleteAllCookies()
Clears the current list of cookies
- MACRO DeleteCookie(STRING cookiename)
Deletes a single cookie
- MACRO DeleteCookies(STRING cookiemask)
Deletes cookies by wildcard mask
- BOOLEAN FUNCTION ExecuteSubmitInstruction(RECORD submitinstruction)
Executes a submit instruction
- RECORD ARRAY FUNCTION GetAllCookies()
Returns the current list of cookies
- STRING FUNCTION GetCookie(STRING cookiename)
Returns the data for a single cookie
- RECORD FUNCTION GetHTTPStatus()
Returns the HTTP status code and message the last request resulted in
- INTEGER FUNCTION GetHTTPStatusCode()
Returns the HTTP status code of the last request resulted in
- STRING FUNCTION GetHTTPStatusText()
Returns the code and message of the last request
- RECORD FUNCTION GetRequestSource()
Returns the current set IP address from which the requests are sent
- STRING FUNCTION GetResponseHeader(STRING headername)
Get a response header by name
- INTEGER FUNCTION GetSocketError()
Returns the socket error of the last request
- RECORD FUNCTION GetSocketStatus()
Returns the socket status of the last request
- BOOLEAN FUNCTION GotoWebPage(STRING url, RECORD options)
Open a URL in the webbrowser (GET request)
- RECORD FUNCTION InvokeJSONRPC(STRING url, STRING methodname, VARIANT ARRAY args2, RECORD options)
Executes a JSON RPC call
- MACRO LoadWebPageFromBlob(STRING baseurl, STRING contenttype, BLOB data)
Open a blob in the webbrowser
- RECORD FUNCTION OpenWebSocket(STRING url, RECORD ARRAY headers)
Opens a websocket
- BOOLEAN FUNCTION PostWebPage(STRING url, RECORD ARRAY variables, STRING enctype, STRING charset)
Submits a POST request
- BOOLEAN FUNCTION PostWebPageBlob(STRING url, RECORD ARRAY headers, BLOB request_body)
Post a URL in a webbrowser
- OBJECT FUNCTION QS(VARIANT ARRAY args)
Get a single element by CSS selector
- OBJECT ARRAY FUNCTION QSA(VARIANT ARRAY args)
Get all elements matching a CSS selector
- BOOLEAN FUNCTION SendRawRequest(STRING method, STRING url, RECORD ARRAY headers, BLOB request_body, RECORD options)
Sends a request
- MACRO SetAuthorization(STRING urlbase, STRING authorizationheader)
Set the authorization header to use for authenticating for a specific URL
- MACRO SetHostnameOverride(STRING hostname, STRING overridewith, RECORD options)
Override hostname resolution (set an IP addres or alternative hostname)
- MACRO SetPassword(STRING urlbase, STRING username, STRING password)
Set the username and password to use for authenticating for a specific URL
- MACRO SetProxyPassword(STRING urlbase, STRING username, STRING password)
Set the username and password to use for authenticating for the proxy for a specific URL
- MACRO SetRequestSource(STRING host, INTEGER port)
Send all requests from a specific IP address
- MACRO SetSessionCookie(STRING cookiename, STRING value)
Sets a cookie
- MACRO SetupWebHareTrustedPort(STRING ip, INTEGER port, STRING useip)
Set up for use of trusted ports (ADDME convert this to 'generic' reconfiguration and routing)
- BOOLEAN FUNCTION SubmitForm(OBJECT tosubmit)
Submits a form on the page