net.CrossDomainRpc Extends goog.events.EventTarget
Creates a new instance of cross domain RPC

Inheritance

Constructor

goog.net.CrossDomainRpc()

Instance Methods

Public Protected Private
detectResponse_(responseDetectorHandle)
Detects response inside request frame
Arguments:
responseDetectorHandle : number
Handle of detector.
code »
getResponseHeader(name) string | undefined
Gets a response header.
Arguments:
name : string
Name of response header.
Returns: string | undefined  Value of response header; undefined if not found.
code »
getResponseJson() Object | undefined
If response is JSON, evaluates it to a JavaScript object and returns it; otherwise returns undefined.
Returns: Object | undefined  JavaScript object if response is in JSON or undefined.
code »
isSuccess() boolean
No description.
Returns: boolean  Whether the request completed with a success.
code »
receiveResponse_()
Receives response by polling to check readiness of response and then reads response frames and assembles response data
code »
reset()
Removes request iframe used.
code »
sendRequest(uriopt_methodopt_paramsopt_headers)
Sends a request across domain.
Arguments:
uri : string
Uri to make request to.
opt_method : string=
Method of request. Default is POST.
opt_params : Object=
Parameters. Each property is turned into a request parameter.
opt_headers : Object=
Map of headers of the request.
code »
addEventListener(typeopt_captureopt_handlerScope)
Use #listen instead, when possible. Otherwise, use goog.events.listen if you are passing Object (instead of Function) as handler. Adds an event listener to the event target. The same handler can only be added once per the type. Even if you add the same handler multiple times using the same type then it will only be called once when the event is dispatched.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope : Object=
Object in whose scope to call the listener.
code »
assertInitialized_()
Asserts that the event target instance is initialized properly.
code »
dispatchEvent()
No description.
code »
disposeInternal()
Removes listeners from this object. Classes that extend EventTarget may need to override this method in order to remove references to DOM Elements and additional listeners.
code »
fireListeners()
No description.
code »
getListener()
No description.
code »
getListeners()
No description.
code »
getParentEventTarget() goog.events.EventTarget
Returns the parent of this event target to use for bubbling.
Returns: goog.events.EventTarget  The parent EventTarget or null if there is no parent.
code »
hasListener()
No description.
code »
listen()
No description.
code »
listenOnce()
No description.
code »
removeAllListeners()
No description.
code »
removeEventListener(typeopt_captureopt_handlerScope)
Use #unlisten instead, when possible. Otherwise, use goog.events.unlisten if you are passing Object (instead of Function) as handler. Removes an event listener from the event target. The handler must be the same object as the one added. If the handler has not been added then nothing is done.
Arguments:
type : string
The type of the event to listen for.
: ?function():? | ?{handleEvent:function():?
No description.
opt_capture : boolean=
In DOM-compliant browsers, this determines whether the listener is fired during the capture or bubble phase of the event.
opt_handlerScope : Object=
Object in whose scope to call the listener.
code »
setParentEventTarget(parent)
Sets the parent of this event target to use for capture/bubble mechanism.
Arguments:
parent : goog.events.EventTarget
Parent listenable (null if none).
code »
setTargetForTesting(target)
Sets the target to be used for event.target when firing event. Mainly used for testing. For example, see goog.testing.events.mixinListenable.
Arguments:
target : !Object
The target.
code »
unlisten()
No description.
code »
unlistenByKey()
No description.
code »
addOnDisposeCallback(callbackopt_scope)
Invokes a callback function when this object is disposed. Callbacks are invoked in the order in which they were added.
Arguments:
callback : function(this:T):?
The callback function.
opt_scope : T=
An optional scope to call the callback in.
code »
dispose() void
Disposes of the object. If the object hasn't already been disposed of, calls #disposeInternal. Classes that extend goog.Disposable should override #disposeInternal in order to delete references to COM objects, DOM nodes, and other disposable objects. Reentrant.
Returns: void  Nothing.
code »
disposeInternal()
Deletes or nulls out any references to COM objects, DOM nodes, or other disposable objects. Classes that extend goog.Disposable should override this method. Not reentrant. To avoid calling it twice, it must only be called from the subclass' disposeInternal method. Everywhere else the public dispose method must be used. For example:
  mypackage.MyClass = function() {
    mypackage.MyClass.base(this, 'constructor');
    // Constructor logic specific to MyClass.
    ...
  };
  goog.inherits(mypackage.MyClass, goog.Disposable);

  mypackage.MyClass.prototype.disposeInternal = function() {
    // Dispose logic specific to MyClass.
    ...
    // Call superclass's disposeInternal at the end of the subclass's, like
    // in C++, to avoid hard-to-catch issues.
    mypackage.MyClass.base(this, 'disposeInternal');
  };
code »
getDisposed() boolean
Use #isDisposed instead. No description.
Returns: boolean  Whether the object has been disposed of.
code »
isDisposed() boolean
No description.
Returns: boolean  Whether the object has been disposed of.
code »
registerDisposable(disposable)
Associates a disposable object with this object so that they will be disposed together.
Arguments:
disposable : goog.disposable.IDisposable
that will be disposed when this object is disposed.
code »

Instance Properties

constructor :
No description.
Code »
actualEventTarget_ : goog.events.EventTarget
The object to use for event.target. Useful when mixing in an EventTarget to another object.
Code »
constructor :
No description.
Code »
eventTargetListeners_ : goog.events.ListenerMap
Maps of event type to an array of listeners.
Code »
parentEventTarget_ : goog.events.EventTarget
Parent event target, used during event bubbling. TODO(user): Change this to goog.events.Listenable. This currently breaks people who expect getParentEventTarget to return goog.events.EventTarget.
Code »
creationStack :
If monitoring the goog.Disposable instances is enabled, stores the creation stack trace of the Disposable instance.
Code »
disposed_ :
Whether the object has been disposed of.
Code »
onDisposeCallbacks_ :
Callbacks to invoke when this object is disposed.
Code »

Static Methods

goog.net.CrossDomainRpc.createInputHtml_(namevalue) string
Creates the HTML of an input element
Arguments:
name : string
Name of input element.
value : *
Value of input element.
Returns: string  HTML of input element with that name and value.
code »
goog.net.CrossDomainRpc.createResponseInfo_(dummyUrinumChunksisDataJsonstatusheaders)
Creates a response info iframe to indicate completion of sendResponse
Arguments:
dummyUri : string
URI to a dummy resource.
numChunks : number
Total number of chunks.
isDataJson : boolean
Whether response is a JSON string or just string.
status : number
HTTP response status code.
headers : string
Response headers in JSON format.
code »
goog.net.CrossDomainRpc.escapeAmpersand_(value) *
Escapes ampersand so that XML/HTML entities are submitted as is because browser unescapes them when they are put into a text area.
Arguments:
value : *
Value to escape.
Returns: *  Value with ampersand escaped, if value is a string; otherwise the value itself is returned.
code »
goog.net.CrossDomainRpc.getDummyResourceUri_() string
Finds a dummy resource that can be used by response to gain domain of requester's page.
Returns: string  URI of the resource to use.
code »
goog.net.CrossDomainRpc.getFramePayload_(frame) string
Returns the payload of a frame (value after # or ? on the URL). This value is URL encoded except IE, where the value is not encoded to begin with.
Arguments:
frame : Object
Frame.
Returns: string  Payload of that frame.
code »
goog.net.CrossDomainRpc.getPayloadDelimiter_(dummyUri) string
Returns payload delimiter, either "#" when caller's page is not used as the dummy resource or "?" when it is, in which case caching issues prevent response frames to gain the caller's domain.
Arguments:
dummyUri : string
URI to resource being used as dummy resource.
Returns: string  Either "?" when caller's page is used as dummy resource or "#" if it is not.
code »
goog.net.CrossDomainRpc.isInResponseIframe_() *
Checks to see if we are executing inside a response iframe. This is the case when this page is used as a dummy resource to gain caller's domain.
Returns: *  True if we are executing inside a response iframe; false otherwise.
code »
goog.net.CrossDomainRpc.isResponseInfoFrame_(frame) boolean
Checks whether a frame is response info frame.
Arguments:
frame : Object
Frame to check.
Returns: boolean  True if frame is a response info frame; false otherwise.
code »
goog.net.CrossDomainRpc.removeHash_(uri) string
Removes everything at and after hash from URI
Arguments:
uri : string
Uri to to remove hash.
Returns: string  Uri with its hash and all characters after removed.
code »
goog.net.CrossDomainRpc.removeUriParams_(uri) string
Removes all parameters (after ? or #) from URI.
Arguments:
uri : string
URI to remove parameters from.
Returns: string  URI with all parameters removed.
code »
goog.net.CrossDomainRpc.send(uriopt_continuationopt_methodopt_paramsopt_headers)
Sends a request across domain.
Arguments:
uri : string
Uri to make request to.
opt_continuation : Function=
Continuation function to be called when request is completed. Takes one argument of an event object whose target has the following properties: "status" is the HTTP response status code, "responseText" is the response text, and "headers" is an object with all response headers. The event target's getResponseJson() method returns a JavaScript object evaluated from the JSON response or undefined if response is not JSON.
opt_method : string=
Method of request. Default is POST.
opt_params : Object=
Parameters. Each property is turned into a request parameter.
opt_headers : Object=
Map of headers of the request.
code »
goog.net.CrossDomainRpc.sendResponse(dataisDataJsonechostatusheaders)
Makes response available for grandparent (requester)'s receiveResponse call to pick up by creating a series of iframes pointed to the dummy URI with a payload (value after either ? or #) carrying a chunk of response data and a response info iframe that tells the grandparent (requester) the readiness of response.
Arguments:
data : string
Response data (string or JSON string).
isDataJson : boolean
true if data is a JSON string; false if just a string.
echo : Object
Parameters to echo back "xdpe:request-id": Server that produces the response needs to copy it here to support multiple current XD requests on the same page. "xdpe:dummy-uri": URI to a dummy resource that response iframes point to to gain the domain of the client. This can be an image (IE) or a CSS file (FF) found on the requester's page. Server should copy value from request parameter "xdpe:dummy-uri".
status : number
HTTP response status code.
headers : string
Response headers in JSON format.
code »
goog.net.CrossDomainRpc.setDebugMode(flag)
Sets debug mode to true or false. When debug mode is on, response iframes are visible and left behind after their use is finished.
Arguments:
flag : boolean
Flag to indicate intention to turn debug model on (true) or off (false).
code »
goog.net.CrossDomainRpc.setDummyResourceUri(dummyResourceUri)
Sets the URI for a dummy resource on caller's domain. This function is used for specifying a particular resource to use rather than relying on auto detection.
Arguments:
dummyResourceUri : string
URI to dummy resource on the same domain of caller's page.
code »
goog.net.CrossDomainRpc.setUseFallBackDummyResource(useFallBack)
Sets whether a fallback dummy resource ("/robots.txt" on Firefox and Safari and current page on IE) should be used when a suitable dummy resource is not available.
Arguments:
useFallBack : boolean
Whether to use fallback or not.
code »

Static Properties

goog.net.CrossDomainRpc.CHUNK_PREFIX_ :
Prefix before data chunk for passing other parameters. type String
Code »
goog.net.CrossDomainRpc.HEADER :
Header prefix.
Code »
goog.net.CrossDomainRpc.MAX_CHUNK_SIZE_ :
Maximal chunk size. IE can only handle 4095 bytes on its URL. 16MB has been tested on Firefox. But 1MB is a practical size.
Code »
goog.net.CrossDomainRpc.PARAM :
Parameter prefix.
Code »
goog.net.CrossDomainRpc.PARAM_CHUNK_ :
Query parameter 'chunk'.
Code »
goog.net.CrossDomainRpc.PARAM_ECHO :
Parameter to echo prefix.
Code »
goog.net.CrossDomainRpc.PARAM_ECHO_DUMMY_URI :
Parameter to echo: dummy resource URI
Code »
goog.net.CrossDomainRpc.PARAM_ECHO_REQUEST_ID :
Parameter to echo: request id
Code »
goog.net.CrossDomainRpc.REFERRER_ :
Referrer of current document with all parameters after "?" and "#" stripped.
Code »
goog.net.CrossDomainRpc.REQUEST_MARKER_ :
Cross-domain request marker.
Code »
goog.net.CrossDomainRpc.RESPONSE_INFO_MARKER_ :
Name of response info iframe.
Code »
goog.net.CrossDomainRpc.RESPONSE_MARKER_ :
Cross-domain response iframe marker.
Code »
goog.net.CrossDomainRpc.RESPONSE_POLLING_PERIOD_ :
period of response polling (ms)
Code »
goog.net.CrossDomainRpc.SEND_RESPONSE_TIME_OUT_ :
timeout from response comes back to sendResponse is called (ms)
Code »
goog.net.CrossDomainRpc.debugMode_ :
No description.
Code »
goog.net.CrossDomainRpc.dummyResourceUri_ :
No description.
Code »
goog.net.CrossDomainRpc.logger_ : goog.debug.Logger
Logger for goog.net.CrossDomainRpc
Code »
goog.net.CrossDomainRpc.nextRequestId_ :
next request id used to support multiple XD requests at the same time
Code »
goog.net.CrossDomainRpc.superClass_ :
No description.
Code »
goog.net.CrossDomainRpc.useFallBackDummyResource_ :
Use a fallback dummy resource if none specified or detected.
Code »

Package net

Package Reference