Detailed Description

The XMLHttpRequest API. Use this from C# too.

Inheritance diagram for PowerUI.XMLHttpRequest:
PowerUI.DataPackage PowerUI.ContentPackage Dom.EventTarget Dom.IEventTarget

Public Member Functions

 XMLHttpRequest (HtmlDocument document)
 Creates a request relative to the given document. More...
 
 XMLHttpRequest ()
 Creates a request. Note that you must use an absolute URL with this one (pass a document otherwise). More...
 
void open (string method, string url)
 Opens the request. More...
 
void open (string method, string url, bool async)
 Opens the request. More...
 
void open (string method, string url, bool async, string user, string password)
 Opens the request. More...
 
void send (byte[] data)
 Send this request with the given post data. More...
 
void send (JSObject data)
 Send this request with the given post data. More...
 
void send (HtmlDocument data)
 Send this request with the given post data. More...
 
void send (string data)
 Send this request with the given post data. More...
 
void setRequestHeader (string header)
 Sets a request header. More...
 
void setRequestHeader (string header, string value)
 Sets a request header. More...
 
string getResponseHeader (string header)
 Specified response header. More...
 
override void send ()
 Send this request. More...
 
string getAllResponseHeaders ()
 The complete header text. More...
 
- Public Member Functions inherited from PowerUI.DataPackage
 DataPackage ()
 
 DataPackage (string src)
 
 DataPackage (string src, Location relativeTo)
 Creates a new package to get the named file. You must then call Get to perform the request. More...
 
- Public Member Functions inherited from PowerUI.ContentPackage
void setRequestBody (Json.JSObject toPost)
 Sets the PostData from the given JSON object. Changes the content type too. More...
 
void setRequestBody (string toPost)
 Sets the PostData from the given UTF8 string. More...
 
void abort ()
 Aborts this request. More...
 
void AttachForm (UnityEngine.WWWForm form)
 Adds the given form to this request. Note that if you wish to also use custom headers with a form, call this first. Then, add to the Headers property. More...
 
void TimedOut ()
 The request has timed out. More...
 
void NotModified (CachedContent cacheEntry)
 A 304 not modified response. More...
 
void SetPartialResponse (int start, int end, int total)
 Sets the Content-Range response. More...
 
bool GetRange (out int start, out int end)
 Gets the range request header. More...
 
void Failed (int status)
 Goes straight to ready state 4 and the given status. More...
 
- Public Member Functions inherited from Dom.EventTarget
void ClearEvents ()
 Clears all events on this document. More...
 
bool dispatchEvent (Event e)
 Runs an event of the given name. More...
 
void addEventListener (string name, EventListener listener)
 Adds an event listener to this document. More...
 
void addEventListener (string name, EventListener listener, bool useCapture)
 Adds an event listener to this document. More...
 
void removeEventListener (string name, object evtHandlerInternal)
 Removes an event listener from this document. More...
 
void addEventListener (string name, AnimationEventDelegate method)
 
void addEventListener (string name, AudioProcessingEventDelegate method)
 
void addEventListener (string name, BeforeInputEventDelegate method)
 
void addEventListener (string name, BeforeUnloadEventDelegate method)
 
void addEventListener (string name, BlobEventDelegate method)
 
void addEventListener (string name, ClipboardEventDelegate method)
 
void addEventListener (string name, CloseEventDelegate method)
 
void addEventListener (string name, CompositionEventDelegate method)
 
void addEventListener (string name, CustomEventDelegate method)
 
void addEventListener (string name, CSSFontFaceLoadEventDelegate method)
 
void addEventListener (string name, DeviceLightEventDelegate method)
 
void addEventListener (string name, DeviceMotionEventDelegate method)
 
void addEventListener (string name, DeviceOrientationEventDelegate method)
 
void addEventListener (string name, DeviceProximityEventDelegate method)
 
void addEventListener (string name, DomEventDelegate method)
 
void addEventListener (string name, DOMTransactionEventDelegate method)
 
void addEventListener (string name, DragEventDelegate method)
 
void addEventListener (string name, EditingBeforeInputEventDelegate method)
 
void addEventListener (string name, ErrorEventDelegate method)
 
void addEventListener (string name, FetchEventDelegate method)
 
void addEventListener (string name, FocusEventDelegate method)
 
void addEventListener (string name, GamepadEventDelegate method)
 
void addEventListener (string name, HashChangeEventDelegate method)
 
void addEventListener (string name, IDBVersionChangeEventDelegate method)
 
void addEventListener (string name, InputEventDelegate method)
 
void addEventListener (string name, KeyboardEventDelegate method)
 
void addEventListener (string name, MediaStreamEventDelegate method)
 
void addEventListener (string name, MessageEventDelegate method)
 
void addEventListener (string name, MouseEventDelegate method)
 
void addEventListener (string name, MutationEventDelegate method)
 
void addEventListener (string name, OfflineAudioCompletionEventDelegate method)
 
void addEventListener (string name, PageTransitionEventDelegate method)
 
void addEventListener (string name, PointerEventDelegate method)
 
void addEventListener (string name, PopStateEventDelegate method)
 
void addEventListener (string name, ProgressEventDelegate method)
 
void addEventListener (string name, RelatedEventDelegate method)
 
void addEventListener (string name, RTCDataChannelEventDelegate method)
 
void addEventListener (string name, RTCIdentityErrorEventDelegate method)
 
void addEventListener (string name, RTCIdentityEventDelegate method)
 
void addEventListener (string name, RTCPeerConnectionIceEventDelegate method)
 
void addEventListener (string name, SensorEventDelegate method)
 
void addEventListener (string name, StorageEventDelegate method)
 
void addEventListener (string name, TextEventDelegate method)
 
void addEventListener (string name, TimeEventDelegate method)
 
void addEventListener (string name, TouchEventDelegate method)
 
void addEventListener (string name, TrackEventDelegate method)
 
void addEventListener (string name, TransitionEventDelegate method)
 
void addEventListener (string name, UIEventDelegate method)
 
void addEventListener (string name, UserProximityEventDelegate method)
 
void addEventListener (string name, WebGLContextEventDelegate method)
 
void addEventListener (string name, WheelEventDelegate method)
 
void addEventListener (string name, Nitro.DynamicMethod< Nitro.Void > listener)
 
void addEventListener (string name, Nitro.DynamicMethod< Nitro.Void > listener, bool capture)
 
void addEventListener (string name, ContextEventDelegate method)
 
void addEventListener (string name, SlideEventDelegate method)
 
void addEventListener (string name, PowerUI.SpriteEventDelegate method)
 
void addEventListener (string name, SVGEventDelegate method)
 Adds an event listener to this document. More...
 
void addEventListener (string name, SVGZoomEventDelegate method)
 

Public Attributes

const short UNSENT =0
 The unsent ready state. More...
 
const short OPENED =1
 The opened ready state. More...
 
const short HEADERS_RECEIVED =2
 The received ready state. More...
 
const short LOADING =3
 The loading ready state. More...
 
const short DONE =4
 The done ready state. More...
 
string responseType =""
 The response type. More...
 
- Public Attributes inherited from PowerUI.DataPackage
byte[] responseBytes
 The data that was retrieved. You must check if it is Ok first. More...
 
- Public Attributes inherited from PowerUI.ContentPackage
Document hostDocument
 A document to inform when the resource has loaded. More...
 
Location redirectedTo
 A location that the request was redirected to. More...
 
Location location
 The URI that was requested. More...
 
byte[] request
 E.g. posted data. More...
 
string type
 The type of file that was requested (e.g. "woff" or "ttf") More...
 
int statusCode =200
 A HTTP status code if there is one. More...
 
int contentLength
 Total content length. More...
 
int bytesReceived
 Bytes received. More...
 
- Public Attributes inherited from Dom.EventTarget
EventsSet Events
 A set of events for this document. See addEventListener. More...
 

Properties

string responseURL [get]
 The URL. More...
 
object response [get]
 A type dependant response. More...
 
- Properties inherited from PowerUI.DataPackage
string responseText [get]
 The response text. More...
 
ushort status [get]
 The HTTP status of the response. More...
 
- Properties inherited from PowerUI.ContentPackage
int readyState [get, set]
 Same as XMLHTTPRequest.readyState. More...
 
Headers requestHeaders [get]
 The headers to send with this request. They're lowercase. Status line is indexed as the empty string. More...
 
Headers responseHeaders [get]
 All available headers, parsed as soon as they become available. Status line is indexed as the empty string. More...
 
string rawResponseHeaders [get, set]
 Gets or sets the raw response headers. More...
 
string rawRequestHeaders [get, set]
 Gets or sets the raw response headers. More...
 
string statusText [get]
 The complete response status header. E.g. "HTTP/1.1 200 OK" More...
 
bool started [get]
 True if this request has started up. More...
 
bool ready [get]
 True if this request has at least some data. More...
 
bool ok [get]
 True if there is no error and the text is ok. More...
 
bool errored [get]
 True if there was an error and the text is not ok. More...
 
string contentType [get]
 The response content type. More...
 
float progress [get]
 Download progress. More...
 
int timeout [get, set]
 Timeout in ms. Default is 0. More...
 
UIEventDelegate onreadystatechange [get, set]
 Called when the ready state changes. More...
 
UIEventDelegate onload [get, set]
 Called when it's done loading. More...
 
UIEventDelegate ontimeout [get, set]
 Called when the request times out. More...
 
UIEventDelegate onerror [get, set]
 Called when the request errors. More...
 
UIEventDelegate onabort [get, set]
 Called when the request is aborted. More...
 
- Properties inherited from Dom.EventTarget
static DispatchStack dispatchStackRef [get]
 The active dispatch stack. Use event.deepPath to access it (available during dispatch only). More...
 
virtual EventTarget eventTargetParentNode [get]
 The parent node as used by EventTarget during capture. Can be null. More...
 
virtual NodeList eventTargetChildren [get]
 The childNode set as used by EventTarget during capture. Can be null. More...
 

Private Attributes

HtmlDocument HostDocument
 The host document. More...
 
string Method ="get"
 The method to use. More...
 

Additional Inherited Members

- Protected Member Functions inherited from PowerUI.ContentPackage
void SetPath (string src, Location relativeTo)
 Sets up the filepath to the given url which may be relative to a given location. More...
 
- Package Functions inherited from PowerUI.DataPackage
override void ReceivedData (byte[] data, int offset, int count)
 Got data is called by the file handler when the response is received. More...
 
- Package Attributes inherited from PowerUI.ContentPackage
int readyState_
 Same as XMLHTTPRequest.readyState. More...
 
IAbortable abortableObject
 An internal abortable object. More...
 
- Static Package Attributes inherited from Dom.EventTarget
static DispatchStack PooledStack
 The current head of the pooled dispatched stacks. More...
 

Constructor & Destructor Documentation

PowerUI.XMLHttpRequest.XMLHttpRequest ( HtmlDocument  document)
inline

Creates a request relative to the given document.

PowerUI.XMLHttpRequest.XMLHttpRequest ( )
inline

Creates a request. Note that you must use an absolute URL with this one (pass a document otherwise).

Member Function Documentation

string PowerUI.XMLHttpRequest.getAllResponseHeaders ( )
inline

The complete header text.

string PowerUI.XMLHttpRequest.getResponseHeader ( string  header)
inline

Specified response header.

void PowerUI.XMLHttpRequest.open ( string  method,
string  url 
)
inline

Opens the request.

void PowerUI.XMLHttpRequest.open ( string  method,
string  url,
bool  async 
)
inline

Opens the request.

void PowerUI.XMLHttpRequest.open ( string  method,
string  url,
bool  async,
string  user,
string  password 
)
inline

Opens the request.

void PowerUI.XMLHttpRequest.send ( byte[]  data)
inline

Send this request with the given post data.

void PowerUI.XMLHttpRequest.send ( JSObject  data)
inline

Send this request with the given post data.

void PowerUI.XMLHttpRequest.send ( HtmlDocument  data)
inline

Send this request with the given post data.

void PowerUI.XMLHttpRequest.send ( string  data)
inline

Send this request with the given post data.

override void PowerUI.XMLHttpRequest.send ( )
inlinevirtual

Send this request.

Reimplemented from PowerUI.DataPackage.

void PowerUI.XMLHttpRequest.setRequestHeader ( string  header)
inline

Sets a request header.

void PowerUI.XMLHttpRequest.setRequestHeader ( string  header,
string  value 
)
inline

Sets a request header.

Member Data Documentation

const short PowerUI.XMLHttpRequest.DONE =4

The done ready state.

const short PowerUI.XMLHttpRequest.HEADERS_RECEIVED =2

The received ready state.

HtmlDocument PowerUI.XMLHttpRequest.HostDocument
private

The host document.

const short PowerUI.XMLHttpRequest.LOADING =3

The loading ready state.

string PowerUI.XMLHttpRequest.Method ="get"
private

The method to use.

const short PowerUI.XMLHttpRequest.OPENED =1

The opened ready state.

string PowerUI.XMLHttpRequest.responseType =""

The response type.

const short PowerUI.XMLHttpRequest.UNSENT =0

The unsent ready state.

Property Documentation

object PowerUI.XMLHttpRequest.response
get

A type dependant response.

string PowerUI.XMLHttpRequest.responseURL
get

The URL.