User Tools
Table of Contents
HTTP Session Manager Scripts
Author: Eoin Joy
These scripts are used to interact with a controller via its web interface, to perform tasks like logging in or posting data.
Object Store JSON
String – This object holds a string of JSON that represents some part of the postData that should always be present, such as what the name of the parameter that holds the cookie is. This naturally is different on a per interface basis.
Safe Login
This script is used to login to the controller and gain some form of cookie or other data that allows the session to survive until the end of the current process.
Return Value
GroovyHttpSessionResult – an object that holds a success flag, as well as the result of the request, the http client used, and the new current object store (say with the logged in cookie included).
Inserted Variables
networkElement – NetworkElement – The NetworkElement being worked upon.
objectStore – Map< String, String > – The current object store, loaded at first with what is in the object store JSON value of this configuration, but updated possibly with things like versions or cookies.
httpClient – Object – Usually a DefaultHttpClient that is used to perform HTTP gets or posts, but in general these are performed by calling the getRequest and postRequest methods which call their respective scripts in this configuration.
headers – Map< String, String > – The headers to be inserted into a HTTP request such as content-type and other headers.
Get Request
This script is used ideally by all other scripts to perform a get request upon a controller with this configuration. It is optionally possible to cache the results of this script by changing the call to it.
Return Value
GroovyHttpSessionResult – an object that holds a success flag, as well as the result of the request, the http client used, and the new current object store (say with the logged in cookie included).
Inserted Variables
networkElement – NetworkElement – The NetworkElement being worked upon.
objectStore – Map< String, String > – The current object store, loaded at first with what is in the object store JSON value of this configuration, but updated possibly with things like versions or cookies.
httpClient – Object – Usually a DefaultHttpClient that is used to perform HTTP gets or posts, but in general these are performed by calling the getRequest and postRequest methods which call their respective scripts in this configuration.
headers – Map< String, String > – The headers to be inserted into a HTTP request such as content-type and other headers.
url – String – The URL of the request.
Post Request
This script is used ideally by all other scripts to perform a POST request to a controller with this configuration.
Return Value
GroovyHttpSessionResult – an object that holds a success flag, as well as the result of the request, the http client used, and the new current object store (say with the logged in cookie included).
Inserted Variables
networkElement – NetworkElement – The NetworkElement being worked upon.
objectStore – Map< String, String > – The current object store, loaded at first with what is in the object store JSON value of this configuration, but updated possibly with things like versions or cookies.
httpClient – Object – Usually a DefaultHttpClient that is used to perform HTTP gets or posts, but in general these are performed by calling the getRequest and postRequest methods which call their respective scripts in this configuration.
headers – Map< String, String > – The headers to be inserted into a HTTP request such as content-type and other headers.
url – String – The URL of the request.
postData – Map< String, String > – The post data to be sent along with the POST, such as form values or JSON.
Cancel
This script ideally cancels the HTTP request that it is passed.
Return Value
void – There is no returned value.
Inserted Variables
cancelable – Object – An object referencing the HTTP request that can be cancelled.
Login Check
This script is unused.