goog.labs.net.webChannel.ChannelRequest
Provided By |
---|
A new ChannelRequest is created for each request to the server.
new ChannelRequest( channel, channelDebug, opt_sessionId, opt_requestId, opt_retryId )
Parameters |
|
---|
Instance Methods
this.cancel() → void
void
Cancels the request no matter what the underlying transport is.
this.getLastError() → (goog.labs.net.webChannel.ChannelRequest.Error|null)
(goog.labs.net.webChannel.ChannelRequest.Error|null)
If the request was not successful, returns the reason.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getLastStatusCode() → number
number
Returns the status code of the last request.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getPendingMessages() → Array<(goog.labs.net.webChannel.Wire.QueuedMap|null)>
Array<(goog.labs.net.webChannel.Wire.QueuedMap|null)>
Gets the pending messages that this request is handling, in case of a retry.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getPostData() → (string|null)
(string|null)
Returns the data for a post, if this request is a post.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getRequestStartTime() → (number|null)
(number|null)
Returns the time that the request started, if it has started.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getSessionId() → (string|undefined)
(string|undefined)
Returns the session id for this channel.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getSuccess() → boolean
boolean
Indicates whether the request was successful. Only valid after the handler is called to indicate completion of the request.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.getXhr() → (goog.net.XhrIo|null)
(goog.net.XhrIo|null)
Returns the XhrIo request object.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.isInitialResponseDecoded() → boolean
boolean
Check if the initial response header has been handled.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.resetTimeout( opt_timeout ) → void
void
this.sendCloseRequest( uri ) → void
void
Uses an IMG tag or navigator.sendBeacon 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.
Navigator.sendBeacon is available on Chrome and Firefox as a formal solution to ensure delivery without blocking window close. See https://developer.mozilla.org/en-US/docs/Web/API/Navigator/sendBeacon
For Chrome Apps, sendBeacon is always necessary due to Content Security Policy (CSP) violation of using an IMG tag.
For react-native, we use xhr to send the actual close request, and assume there is no page-close issue with react-native.
Parameters |
|
---|
this.setDecodeInitialResponse() → void
void
Decodes X_HTTP_INITIAL_RESPONSE if present.
this.setExtraHeaders( extraHeaders ) → void
void
Sets extra HTTP headers to add to all the requests sent to the server.
Parameters |
|
---|
this.setPendingMessages( pendingMessages ) → void
void
Sets the pending messages that this request is handling.
Parameters |
|
---|
this.setReadyStateChangeThrottle( throttle ) → void
void
Sets the throttle for handling onreadystatechange events for the request.
Parameters |
|
---|
this.setTimeout( timeout ) → void
void
Sets the timeout for a request
Parameters |
|
---|
this.setVerb( verb ) → void
void
this.xmlHttpGet( uri, decodeChunks, hostPrefix ) → void
void
Uses XMLHTTP to send an HTTP GET to the server.
Parameters |
|
---|
this.xmlHttpPost( uri, postData, decodeChunks ) → void
void
Static Functions
ChannelRequest.createChannelRequest( channel, channelDebug, opt_sessionId, opt_requestId, opt_retryId ) → goog.labs.net.webChannel.ChannelRequest
goog.labs.net.webChannel.ChannelRequest
Convenience factory method.
Parameters |
| ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
ChannelRequest.errorStringFromCode( errorCode, statusCode ) → string
string
Returns a useful error string for debugging based on the specified error code.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
ChannelRequest.supportsXhrStreaming() → boolean
boolean
Returns whether XHR streaming is supported on this browser.
Parameters | None. | ||
---|---|---|---|
Returns |
| ||
See Also | http://code.google.com/p/closure-library/issues/detail?id=346 |