The goog.net.ChannelRequest Class

goog.net.ChannelRequest(channel, channelDebug, opt_sessionId, opt_requestId, opt_retryId)

Creates a ChannelRequest object which encapsulates a request to the server. A new ChannelRequest is created for each request to the server.

channel {goog.net.BrowserChannel|goog.net.BrowserTestChannel}
The BrowserChannel that owns this request.
channelDebug {goog.net.ChannelDebug}
A ChannelDebug to use for logging.
opt_sessionId {string=}
The session id for the channel.
opt_requestId {string|number=}
The request id for this request.
opt_retryId {number=}
The retry id for this request.

The goog.net.ChannelRequest.Error Enum

Enum type for identifying a ChannelRequest error. … more

.POLLING_INTERVAL_MS {number}

How often to poll (in MS) for changes to responseText in browsers that don't fire onreadystatechange during incremental loading of responseText.

.TIMEOUT_MS {number}

Default timeout in MS for a request. The server must return data within this time limit for the request to not timeout.

.cancel()

Cancels the request no matter what the underlying transport is.

.errorStringFromCode(errorCode, statusCode)

Returns a useful error string for debugging based on the specified error code.

errorCode {goog.net.ChannelRequest.Error}
The error code.
statusCode {number}
The HTTP status code.
returns {string}
The error string for the given code combination.

.getLastError()

If the request was not successful, returns the reason.

returns {?goog.net.ChannelRequest.Error}
The last error.

.getLastStatusCode()

Returns the status code of the last request.

returns {number}
The status code of the last request.

.getPostData()

Returns the data for a post, if this request is a post.

returns {?string}
The POST data provided by the request initiator.

.getRequestId()

Returns the request id for this request. Each request has a unique request id and the request IDs are a sequential increasing count.

returns {string|number|undefined}
The request ID.

.getRequestStartTime()

Returns the time that the request started, if it has started.

returns {?number}
The time the request started, as returned by goog.now().

.getSessionId()

Returns the session id for this channel.

returns {string|undefined}
The session ID.

.getSuccess()

Indicates whether the request was successful. Only valid after the handler is called to indicate completion of the request.

returns {boolean}
True if the request succeeded.

.sendUsingImgTag(uri)

Uses an IMG tag to send an HTTP get to the server. This is only currently used to terminate the connection, as an IMG tag is the most reliable way to send something to the server while the page is getting torn down.

uri {goog.Uri}
The uri to send a request to.

.setExtraHeaders(extraHeaders)

Sets extra HTTP headers to add to all the requests sent to the server.

extraHeaders {Object}
The HTTP headers.

.setTimeout(timeout)

Sets the timeout for a request

timeout {number}
The timeout in MS for when we fail the request.

.supportsXhrStreaming()

Returns whether XHR streaming is supported on this browser. If XHR streaming is not supported, we will try to use an ActiveXObject to create a Forever IFrame.

returns {boolean}
Whether XHR streaming is supported.
@see
http://code.google.com/p/closure-library/issues/detail?id=346

.tridentGet(uri, usingSecondaryDomain)

Uses the Trident htmlfile ActiveX control to send a GET request in IE. This is the innovation discovered that lets us get intermediate results in Internet Explorer. Thanks to http://go/kev

uri {goog.Uri}
The uri to request from.
usingSecondaryDomain {boolean}
Whether to use a secondary domain.

.xmlHttpGet(uri, decodeChunks, hostPrefix, opt_noClose)

Uses XMLHTTP to send an HTTP GET to the server.

uri {goog.Uri}
The uri of the request.
decodeChunks {boolean}
Whether to the result is expected to be encoded for chunking and thus requires decoding.
hostPrefix {?string}
The host prefix, if we might be using a secondary domain. Note that it should also be in the URL, adding this won't cause it to be added to the URL.
opt_noClose {boolean=}
Whether to request that the tcp/ip connection should be closed.

.xmlHttpPost(uri, postData, decodeChunks)

Uses XMLHTTP to send an HTTP POST to the server.

uri {goog.Uri}
The uri of the request.
postData {string}
The data for the post body.
decodeChunks {boolean}
Whether to the result is expected to be encoded for chunking and thus requires decoding.