OverviewSingleDeprecated

jsx3.net

class Request

Object
->jsx3.lang.Object
  ->jsx3.net.Request

All Implemented Interfaces:

jsx3.util.EventDispatcher

class Request
extends jsx3.lang.Object
A generic wrapper to hide the complexities and API-specifics of the native XMLHTTP control for a given browser. Developers wishing to create/modify XML documents can use this class to access common XMLHTTP methods.

Note that when using this interface to post xml content to a server, the called server may expect the content type to be set for the posting. For example, objRequest.setRequestHeader("Content-Type", "text/xml");

Field Summary
static String
EVENT_ON_RESPONSE
Event type published when the response has loaded.
static String
EVENT_ON_TIMEOUT
Event type published when the server has not responded after the specified timeout period.
Constructor Summary
void
init(id : String)
The instance initializer.
Method Summary
jsx3.net.Request
Aborts the request.
static void
cancelRequest(strRequestId : String)
Deprecated. Use abort() instead.
String
Gets the value of all the HTTP headers.
int
Deprecated. This method is not consistent between browsers. Use the event publisher interface instead to track the state of the request.
static jsx3.net.Request
getRequest(strRequestId : String)
Deprecated. Static access to pending requests by id is deprecated.
String
Gets the value of a specific HTTP response header.
String
Gets the content of the response as string.
jsx3.xml.Document
Gets the content of the response as an XML document.
int
Gets the HTTP response code (e.g.
String
Gets the HTTP response line status (e.g.
String
Gets the URL passed when opening this request.
static String
Deprecated.
jsx3.net.Request
open(strMethod : String, strURL : String | jsx3.net.URI, bAsync : boolean, strUser : String, strPass : String)
Initializes the request, and specifies the method, URL, and authentication information for the request.
jsx3.net.Request
send(strContent : String, intTimeout : int)
Sends the request.
jsx3.net.Request
setRequestHeader(strName : String, strValue : String)
Sets the value of a specific HTTP request header.
jsx3.net.Request
setTimeouts(intResolveTimeout : int, intConnectTimeout : int, intSendTimeout : int, intReceiveTimeout : int)
Deprecated. IE only.
Methods Inherited From jsx3.util.EventDispatcher
publish, subscribe, unsubscribe, unsubscribeAll
Methods Inherited From jsx3.lang.Object
clone, equals, eval, getClass, getInstanceOf, getInstanceOfClass, getInstanceOfPackage, instanceOf, isInstanceOf, isSubclassOf, jsxmix, jsxsuper, jsxsupermix, setInstanceOf, toString
Field Detail

EVENT_ON_RESPONSE

static final String EVENT_ON_RESPONSE
Event type published when the response has loaded.

EVENT_ON_TIMEOUT

static final String EVENT_ON_TIMEOUT
Event type published when the server has not responded after the specified timeout period.
Constructor Detail

init

void init(id : String)
The instance initializer.

Parameters:

idIf the call will be asynchronous, assigns a unique identifier.
Method Detail

abort

jsx3.net.Request abort()
Aborts the request.

Returns:

this object.  

cancelRequest

static void cancelRequest(strRequestId : String)
Deprecated. Use abort() instead.
Cancels the named request.

Parameters:

strRequestIdnamed id for the request (assigned by developer when the Request was instanced);

See Also:

abort()

getAllResponseHeaders

String getAllResponseHeaders()
Gets the value of all the HTTP headers.

Returns:

 

getReadyState

int getReadyState()
Deprecated. This method is not consistent between browsers. Use the event publisher interface instead to track the state of the request.
Gets the ready state for the request; return values include: 0) The object has been created, but not initialized (the open method has not been called). 1) The object has been created, but the send method has not been called. 2) The send method has been called, but the status and headers are not yet available. 3) Some data has been received. Calling the responseBody and responseText properties at this state to obtain partial results will return an error, because status and response headers are not fully available. 4) All the data has been received, and the complete data is available via the getResponseText()/getResponseXML() methods

Returns:

 

getRequest

static jsx3.net.Request getRequest(strRequestId : String)
Deprecated. Static access to pending requests by id is deprecated.
Gets the named request instance.

Parameters:

strRequestIdnamed id for the request (assigned by developer when the Request was instanced);

Returns:

 

getResponseHeader

String getResponseHeader(strName : String)
Gets the value of a specific HTTP response header.

Parameters:

strNamethe name for the response header to retrieve.

Returns:

 

getResponseText

String getResponseText()
Gets the content of the response as string.

Returns:

 

getResponseXML

jsx3.xml.Document getResponseXML()
Gets the content of the response as an XML document. If the response is not a valid XML document, null is returned.

Returns:

 

getStatus

int getStatus()
Gets the HTTP response code (e.g. 200, 404, 500, etc).

Returns:

 

getStatusText

String getStatusText()
Gets the HTTP response line status (e.g. "OK").

Returns:

 

getURL

String getURL()
Gets the URL passed when opening this request.

Returns:

 

getVersion

static String getVersion()
Deprecated.
gets the release/build for the class (i.e., "3.0.00")

Returns:

 

open

jsx3.net.Request open(strMethod : String, strURL : String | jsx3.net.URI, bAsync : boolean, strUser : String, strPass : String)
Initializes the request, and specifies the method, URL, and authentication information for the request.

Parameters:

strMethodThe HTTP method used to open the connection. Valid values include: GET, POST, or PUT.
strURLThe requested URL. This can be either an absolute URL, such as "http://www.TIBCO.com", or a relative URL, such as "../MyPath/MyFile".
bAsyncwhether to issue the request asynchronously, if true this class will use the EventDispatcher interface to publish an event on response or timeout.
strUserThe name of the user for authentication. If this parameter is null ("") or missing and the site requires authentication, the native HTTP control will display a logon window.
strPassThe password for authentication. This parameter is ignored if the user parameter is null ("") or missing.

Returns:

this object.  

send

jsx3.net.Request send(strContent : String, intTimeout : int)
Sends the request.

Parameters:

strContentThe content to send for a POST request.
intTimeoutthe number milliseconds to wait before publishing a timeout event. This only applies to asynchronous requests. If used, subscribe to the jsx3.net.Request.EVENT_ON_TIMEOUT event to be notified of a timeout.

Returns:

this object.  

setRequestHeader

jsx3.net.Request setRequestHeader(strName : String, strValue : String)
Sets the value of a specific HTTP request header. The open() method should be called before calling this method.

Parameters:

strNamethe name for the request header to send to the server with the request content.
strValuethe value for the request header to send to the server with the request content.

Returns:

this object.  

setTimeouts

jsx3.net.Request setTimeouts(intResolveTimeout : int, intConnectTimeout : int, intSendTimeout : int, intReceiveTimeout : int)
Deprecated. IE only.
Specifies timeout settings for resolving the domain name, establishing the connection to the server, sending the data, and receiving the response. The timeout parameters of the setTimeouts method are specified in milliseconds, so a value of 1000 would represent 1 second. A value of zero represents an infinite timeout. There are four separate timeout parameters: resolveTimeout, connectTimeout, sendTimeout, and receiveTimeout. When calling the setTimeouts method, all four values must be specified. The timeouts are applied at the Winsock layer.

Parameters:

intResolveTimeoutThe value is applied to mapping host names (such as "www.microsoft.com") to IP addresses; the default value is infinite, meaning no timeout.
intConnectTimeoutThe value is applied to establishing a communication socket with the target server, with a default timeout value of 60 seconds.
intSendTimeoutThe value applies to sending an individual packet of request data (if any) on the communication socket to the target server. A large request sent to a server will normally be broken up into multiple packets; the send timeout applies to sending each packet individually. The default value is 5 minutes.
intReceiveTimeoutThe value applies to receiving a packet of response data from the target server. Large responses will be broken up into multiple packets; the receive timeout applies to fetching each packet of data off the socket. The default value is 60 minutes.

Returns:

this instance.