Developer Resources
HttpRequest
Overview
HttpRequest allows the user to communicate with HTTP Servers. Both the normal and the secure HTTPS protocols are supported.
Constructor
- HttpRequest()
Methods
- HttpRequest.clearRequestHeaders
- Clears all the header items from the list of header items to send when issuing an HTTP request.
- HttpRequest.get
- Issues an HTTP GET request.
- HttpRequest.head
- Issues an HTTP HEAD request.
- HttpRequest.post
- Issues an HTTP POST request.
- HttpRequest.resetPostParameters
- Clears the post parameters.
- HttpRequest.setAutoEncode
- Enables or disables url encoding
- HttpRequest.setBasicAuth
- Sets the login and password for the HTTP request.
- HttpRequest.setPostData
- Allows the post data payload to be set directly
- HttpRequest.setPostFile
- Sets a form field to a specified filename.
- HttpRequest.setPostValue
- Sets a form field to a specified value.
- HttpRequest.setProxy
- Sets the proxy information for the HTTP request.
- HttpRequest.setReferrer
- Sets the referrer to use when issuing the HTTP request.
- HttpRequest.setRequestHeader
- Adds a header item to the list of header items to send when issuing an HTTP request.
- HttpRequest.setUserAgent
- Sets the user agent to use when issuing the HTTP request.
Example
var http, result;
// getting a web page
http = new HttpRequest;
result = http.get("http://my.sample.domain.com");
alert(result);
// an example demonstrating basic authentication
http = new HttpRequest;
http.setBasicAuth("test", "this");
result = http.get("http://my.sample.domain.com");
alert(result);
// an example post method call
http = new HttpRequest;
http.setPostValue("form_element1", "123");
http.setPostValue("form_element2", "456");
result = http.post("http://my.sample.domain.com");
alert(result);
HttpRequest.clearRequestHeaders
- function HttpRequest.clearRequestHeaders()
Description
Clears all the header items from the list of header items to send when issuing an HTTP request.
HttpRequest.get
- function HttpRequest.get(location : String) : String
Arguments
- location
- The URI location to which to issue the GET request.
Returns
Returns a string containing the results returned by the server.
Description
Issues an HTTP GET request to the specified location and returns the results returned by the server as a string.
HttpRequest.head
- function HttpRequest.head(location : String) : String
Arguments
- location
- The URI location to which to issue the HEAD request.
Returns
Returns a string containing the results returned by the server.
Description
Issues an HTTP HEAD request to the specified location and returns the results returned by the server as a string.
HttpRequest.post
- function HttpRequest.post(location : String) : String
Arguments
- location
- The URI location to which to issue the POST request.
Returns
Returns a string containing the results returned by the server.
Description
Issues an HTTP POST request to the specified location and returns the results returned by the server as a string. After the post operation is complete, the post parameter array is automatically cleared out.
HttpRequest.resetPostParameters
- function HttpRequest.resetPostParameters()
Description
Clears the post parameters.
HttpRequest.setAutoEncode
- function HttpRequest.setAutoEncode(value : Boolean)
Arguments
- value
- True if url encoding it is to be enabled, false otherwise
Description
Sets whether the HttpRequest object should automatically encode GET and POST parameters with url encoding.
HttpRequest.setBasicAuth
- function HttpRequest.setBasicAuth(login : String, password : String)
Arguments
- login
- The login to use for the HTTP Request.
- password
- The password to use for the HTTP Request.
Description
Sets the login and password for the HTTP request.
HttpRequest.setPostData
- function HttpRequest.setPostFile(post_string : String) : Boolean
Arguments
- post_string
- POST method data payload
Returns
Returns true upon success, false otherwise
Description
Calling setPostData() allows the post data payload to be set directly, in contrast with setPostValue(), which automatically constructs the standard key=value format.
HttpRequest.setPostFile
- function HttpRequest.setPostFile(field : String, filename : String) : Boolean
Arguments
- field
- The form field to set.
- filename
- The filename to which to set the form field.
Returns
Returns true if the form field was set to the specified filename, and false otherwise.
Description
Sets a form field to a specified filename.
HttpRequest.setPostValue
- function HttpRequest.setPostValue(field : String, value : String) : Boolean
Arguments
- field
- The form field for which to set the value.
- value
- The value to which to set the form field.
Returns
Returns true if the form field was set to the specified value, and false otherwise.
Description
Sets a form field to a specified value, which will be used when issuing an HTTP POST request.
HttpRequest.setProxy
- function HttpRequest.setProxy(location : String, port : Integer, login : String, password : String)
Arguments
- location
- The location of the proxy server.
- port
- The port on which to connect to the proxy.
- login
- The login to use when connecting to the proxy.
- password
- The password to use when connecting to the proxy.
Description
Sets the proxy location and, optionally, the proxy port, login, and password.
HttpRequest.setReferrer
- function HttpRequest.setReferrer(referrer : String)
Arguments
- referrer
- The referrer to use when issuing the HTTP request.
Description
Sets the referrer to use when issuing the HTTP request.
HttpRequest.setRequestHeader
- function HttpRequest.setRequestHeader(header : String)
Arguments
- header
- The header to add to the list of headers sent in the HTTP request.
Description
Adds a header item to the list of header items to send when issuing an HTTP request.
HttpRequest.setUserAgent
- function HttpRequest.setUserAgent(agent : String)
Arguments
- agent
- The agent to use when issuing the HTTP request.
Description
Sets the user agent to use when issuing the HTTP request.

