labs.net.webChannel.ChannelRequest Extends
A new ChannelRequest is created for each request to the server.

Inheritance

Constructor

goog.labs.net.webChannel.ChannelRequest(channelchannelDebugopt_sessionIdopt_requestIdopt_retryId)

Parameters

channel : goog.labs.net.webChannel.Channel
The channel that owns this request.
channelDebug : goog.labs.net.webChannel.WebChannelDebug
A WebChannelDebug 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.

Instance Methods

Public Protected Private
cancel()
Cancels the request no matter what the underlying transport is.
code »
cancelRequestAsBrowserIsOffline_()
Called when the browser declares itself offline at the start of a request or during its lifetime. Abandons that request.
code »
cancelWatchDogTimer_()
Cancels the watchdog timer if it has been started.
code »
cleanup_()
Cleans up the objects used to make the request. This function is idempotent.
code »
decodeNextChunks_(readyStateresponseText)
Decodes the next set of available chunks in the response.
Arguments:
readyState : number
The value of readyState.
responseText : string
The value of responseText.
code »
dispatchFailure_()
Notifies the channel that this request failed.
code »
ensureWatchDogTimer_()
Ensures that there is watchdog timeout which is used to ensure that the connection completes in time.
code »
getLastError() ?ChannelRequest.Error
If the request was not successful, returns the reason.
Returns: ?ChannelRequest.Error  The last error.
code »
getLastStatusCode() number
Returns the status code of the last request.
Returns: number  The status code of the last request.
code »
getNextChunk_(responseText) string | Object
Returns the next chunk of a chunk-encoded response. This is not standard HTTP chunked encoding because browsers don't expose the chunk boundaries to the application through XMLHTTP. So we have an additional chunk encoding at the application level that lets us tell where the beginning and end of individual responses are so that we can only try to eval a complete JS array. The encoding is the size of the chunk encoded as a decimal string followed by a newline followed by the data.
Arguments:
responseText : string
The response text from the XMLHTTP response.
Returns: string | Object  The next chunk string or a sentinel object indicating a special condition.
code »
getPostData() ?string
Returns the data for a post, if this request is a post.
Returns: ?string  The POST data provided by the request initiator.
code »
getRequestId() string | number | undefined
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.
code »
getRequestStartTime() ?number
Returns the time that the request started, if it has started.
Returns: ?number  The time the request started, as returned by goog.now().
code »
getSessionId() string | undefined
Returns the session id for this channel.
Returns: string | undefined  The session ID.
code »
getSuccess() boolean
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.
code »
getXhr() ?goog.net.XhrIo
Returns the XhrIo request object.
Returns: ?goog.net.XhrIo  Any XhrIo request created for this object.
code »
handleTimeout_()
Called when the request has actually timed out. Will cleanup and notify the channel of the failure.
code »
imgTagGet_()
Starts the IMG request.
code »
onTridentDoneAsync_(successful)
Callback from the Trident htmlfile ActiveX control for when the request is complete
Arguments:
successful : boolean
Whether the request successfully completed.
code »
onTridentDone_(successful)
Callback from the Trident htmlfile ActiveX control for when the request is complete
Arguments:
successful : boolean
Whether the request successfully completed.
code »
onTridentRpcMessageAsync_(msg)
Callback from the Trident htmlfile ActiveX control for when a new message is received.
Arguments:
msg : string
The data payload.
code »
onTridentRpcMessage_(msg)
Callback from the Trident htmlfile ActiveX control for when a new message is received.
Arguments:
msg : string
The data payload.
code »
onWatchDogTimeout_()
Called when the watchdog timer is triggered. It also handles a case where it is called too early which we suspect may be happening sometimes (not sure why)
code »
onXmlHttpReadyStateChanged_()
Called by the readystate handler for XMLHTTP requests.
code »
pollResponse_()
Polls the response for new data.
code »
readyStateChangeHandler_(evt)
Handles a readystatechange event.
Arguments:
evt : goog.events.Event
The event.
code »
safeOnRequestData_(data)
Helper to call the callback's onRequestData, which catches any exception and cleans up the request.
Arguments:
data : string
The request data.
code »
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.
Arguments:
uri : goog.Uri
The uri to send a request to.
code »
sendXmlHttp_(hostPrefix)
Sends a request via XMLHTTP according to the current state of the request object.
Arguments:
hostPrefix : ?string
The host prefix, if we might be using a secondary domain.
code »
setExtraHeaders(extraHeaders)
Sets extra HTTP headers to add to all the requests sent to the server.
Arguments:
extraHeaders : Object
The HTTP headers.
code »
setReadyStateChangeThrottle(throttle)
Sets the throttle for handling onreadystatechange events for the request.
Arguments:
throttle : number
The throttle in ms. A value of zero indicates no throttle.
code »
setTimeout(timeout)
Sets the timeout for a request
Arguments:
timeout : number
The timeout in MS for when we fail the request.
code »
startPolling_()
Starts a polling interval for changes to responseText of the XMLHttpRequest, for browsers that don't fire onreadystatechange as data comes in incrementally. This timer is disabled in cleanup_().
code »
startWatchDogTimer_(time)
Starts the watchdog timer which is used to ensure that the connection completes in time.
Arguments:
time : number
The number of milliseconds to wait.
code »
tridentGet(uriusingSecondaryDomain)
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
Arguments:
uri : goog.Uri
The uri to request from.
usingSecondaryDomain : boolean
Whether to use a secondary domain.
code »
tridentGet_(usingSecondaryDomain)
Starts the Trident request.
Arguments:
usingSecondaryDomain : boolean
Whether to use a secondary domain.
code »
xmlHttpGet(uridecodeChunkshostPrefixopt_noCloseopt_duplicateRandom)
Uses XMLHTTP to send an HTTP GET to the server.
Arguments:
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.
opt_duplicateRandom : boolean=
Whether to duplicate the randomness parameter which is only required for the initial handshake. This allows a server to break compatibility with old version clients.
code »
xmlHttpHandler_(xmlhttp)
XmlHttp handler
Arguments:
xmlhttp : goog.net.XhrIo
The XhrIo object for the current request.
code »
xmlHttpPost(uripostDatadecodeChunks)
Uses XMLHTTP to send an HTTP POST to the server.
Arguments:
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.
code »

Instance Properties

baseUri_ : goog.Uri
The base Uri for the request. The includes all the parameters except the one that indicates the retry number.
Code »
cancelled_ :
Whether the request has been cancelled due to a call to cancel.
Code »
The channel debug to use for logging
Code »
The channel object that owns the request.
Code »
decodeChunks_ :
Whether to the result is expected to be encoded for chunking and thus requires decoding.
Code »
eventHandler_ : goog.events.EventHandler
An object to keep track of the channel request event listeners.
Code »
extraHeaders_ :
Extra HTTP headers to add to all the requests sent to the server.
Code »
lastError_ :
The last error if the request failed.
Code »
lastStatusCode_ :
The last status code received.
Code »
pollingTimer_ : goog.Timer
A timer for polling responseText in browsers that don't fire onreadystatechange during incremental loading of responseText.
Code »
postData_ :
The post data, if the request is a post.
Code »
readyStateChangeThrottleMs_ :
A throttle time in ms for readystatechange events for the backchannel. Useful for throttling when ready state is INTERACTIVE (partial data). If set to zero no throttle is used. See WebChannelBase.prototype.readyStateChangeThrottleMs_
Code »
readyStateChangeThrottle_ : goog.async.Throttle
The throttle for readystatechange events for the current request, or null if there is none.
Code »
requestStartTime_ :
The time the request started.
Code »
requestUri_ : goog.Uri
The request Uri that was actually used for the most recent request attempt.
Code »
retryId_ :
The attempt number of the current request.
Code »
rid_ :
The RID (request ID) for the request.
Code »
sendClose_ :
Whether to send the Connection:close header as part of the request.
Code »
sid_ :
The Session ID for the channel.
Code »
successful_ :
Whether the request was successful. This is only set to true after the request successfully completes.
Code »
timeout_ :
The timeout in ms before failing the request.
Code »
trident_ :
The Trident instance if the request is using Trident.
Code »
type_ :
The type of request (XMLHTTP, IMG, Trident)
Code »
verb_ :
The verb (Get or Post) for the request.
Code »
watchDogTimeoutTime_ :
The time in the future when the request will timeout.
Code »
watchDogTimerId_ :
The TimerID of the timer used to detect if the request has timed-out.
Code »
xmlHttpChunkStart_ :
The position of where the next unprocessed chunk starts in the response text.
Code »
xmlHttp_ : goog.net.XhrIo
The XhrLte request if the request is using XMLHTTP
Code »

Static Methods

goog.labs.net.webChannel.ChannelRequest.createChannelRequest(channelchannelDebugopt_sessionIdopt_requestIdopt_retryId) !ChannelRequest
Convenience factory method.
Arguments:
channel : Channel
The channel object that owns this request.
channelDebug : WebChannelDebug
A WebChannelDebug 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.
Returns: !ChannelRequest  The created channel request.
code »
goog.labs.net.webChannel.ChannelRequest.errorStringFromCode(errorCodestatusCode) string
Returns a useful error string for debugging based on the specified error code.
Arguments:
errorCode : ?ChannelRequest.Error
The error code.
statusCode : number
The HTTP status code.
Returns: string  The error string for the given code combination.
code »
goog.labs.net.webChannel.ChannelRequest.supportsXhrStreaming() boolean
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.
code »

Static Properties

goog.labs.net.webChannel.ChannelRequest.INCOMPLETE_CHUNK_ :
Sentinel value used to indicate an incomplete chunk in a multi-chunk response.
Code »
goog.labs.net.webChannel.ChannelRequest.INVALID_CHUNK_ :
Sentinel value used to indicate an invalid chunk in a multi-chunk response.
Code »
goog.labs.net.webChannel.ChannelRequest.POLLING_INTERVAL_MS_ :
How often to poll (in MS) for changes to responseText in browsers that don't fire onreadystatechange during incremental loading of responseText.
Code »
goog.labs.net.webChannel.ChannelRequest.TIMEOUT_MS_ :
Default timeout in MS for a request. The server must return data within this time limit for the request to not timeout.
Code »

Enumerations

goog.labs.net.webChannel.ChannelRequest.Error :
Enum type for identifying an error.
Constants:
ACTIVE_X_BLOCKED
No description.
BAD_DATA
No description.
BROWSER_OFFLINE
No description.
HANDLER_EXCEPTION
No description.
NO_DATA
No description.
STATUS
No description.
TIMEOUT
No description.
UNKNOWN_SESSION_ID
No description.
Code »
goog.labs.net.webChannel.ChannelRequest.Type_ :
Enum for channel requests type
Constants:
IMG
No description.
TRIDENT
No description.
XML_HTTP
No description.
Code »

Package labs.net.webChannel

Package Reference