- requestheader : string containing HTTP request header, as generated by user's browser
- httprequest : string containing HTTP request body, or null if none. Note that HTTP request body is only provided for POST requests.
- user_id : string containing either user id (login) or user ip address. User ID will be available if authentication is activated on HTTP proxy.
- user_group : string containing user group if available, or null if not. User group might be available if authentication is activated on HTTP proxy.
- sharedcache : a java hash table<String, Object> that is shared between all scripts
All information is provided as string to avoid casting on Script Engine side, except the shared cache which is transmitted as a Java hashtable. To use this hash table, standard Java methods must be used:
- get(<string>key) to retrieve content associated to given key
- put(<string>key, <object>value) to store a content in the table using given key
Any modification made on HTTP request header and/or body will be handled by GreasySpoon service and will be reflected to the user's request. It is also possible to directly return a response to the user by changing HTTP request line (GET/POST/... something) by an HTTP response code (HTTP/1.0 200 OK for example).
Two examples are provided hereafter showing the possibilities of requests scripts:
» A request anonymizer script can that illustrates how to modify requests headers
» A basic access control script that blocks access to some URLs