Detailed Description

Represents a single http request.

Public Member Functions

void CacheImage ()
 Caches the image in this HTTP request. Useful for preloading images with ajax. More...
 
 HttpRequest (string url, OnHttpEvent onDone)
 Creates a new http request to the given url. More...
 
 HttpRequest (string url)
 Creates a new http request to the given URL. More...
 
void AttachForm (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 SetHeaders (Hashtable headers)
 Unavailable on Windows 8. Sets the headers using a hashtable set. More...
 
void SetHeaders (Dictionary< string, string > headers)
 Sets the headers using a generic dictionary set. More...
 
void SetPost (string toPost)
 Sets the PostData from the given UTF8 string. More...
 
void Send ()
 Sends this request. Note that this does not block. Instead, OnRequestDone will be called when it's done. More...
 
void Remove ()
 Removes this request from the active linked list. It won't be updated anymore. More...
 
void Remove (bool waitingList)
 Removes this request from a linked list. More...
 
IEnumerator Loader ()
 The method which performs the loading of the unity WWW object. More...
 
void Update ()
 Advances this request by checking in on it's progress. More...
 

Public Attributes

bool Ready
 True if the request is ready (but not necessarily complete). More...
 
string Url
 The url that was requested. More...
 
bool Started
 True when this request has started up. More...
 
WWW WWWRequest
 The unity WWW object which performs the underlying request. More...
 
byte[] PostData
 Post data to send with the request. See AttachForm. More...
 
object ExtraData
 A custom object used for passing data to the callbacks. More...
 
Dictionary< string, string > Headers
 The headers sent with this request. More...
 
MovieTexture Movie
 The video being downloaded, if any. Note: Pro only. More...
 
HttpRequest RequestAfter
 Active requests are in a linked list. The http request that follows this one. More...
 
HttpRequest RequestBefore
 Active requests are in a linked list. The http request that is before this one. More...
 

Properties

bool Errored [get]
 True if the request had an issue. PowerUI.HttpRequest.Error is the error. More...
 
bool Ok [get]
 True if there was no issues. More...
 
string Error [get]
 The error, if any, that occured whilst attempting to load the url. More...
 
string Text [get]
 The response as text. Empty string if there was an error. More...
 
byte[] Bytes [get]
 The raw bytes of the response. Null if there was an error. More...
 
MovieTexture Video [get]
 The response as a video. Null if there was an error. More...
 
Texture2D Image [get]
 The response as an image. Null if there was an error. More...
 
float Progress [get]
 The current download progress. More...
 

Events

OnHttpEvent OnRequestDone
 An event called when the request is completely finished. More...
 
OnHttpEvent OnRequestReady
 An event called when the data is ready for use (e.g. videos). More...
 

Private Member Functions

Dictionary< string, string > ToDictionary (Hashtable headers)
 Converts a hashtable to a dictionary. More...
 

Private Attributes

IEnumerator LoadingEnumerator
 The enumerator which processes the unity WWW object. More...
 

Constructor & Destructor Documentation

UnityHttp.HttpRequest.HttpRequest ( string  url,
OnHttpEvent  onDone 
)
inline

Creates a new http request to the given url.

Parameters
urlThe url to request.
onDoneA method to call with the result.
UnityHttp.HttpRequest.HttpRequest ( string  url)
inline

Creates a new http request to the given URL.

Parameters
urlThe url to request.

Member Function Documentation

void UnityHttp.HttpRequest.AttachForm ( WWWForm  form)
inline

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.

Parameters
formThe form to attach to this request.
void UnityHttp.HttpRequest.CacheImage ( )
inline

Caches the image in this HTTP request. Useful for preloading images with ajax.

IEnumerator UnityHttp.HttpRequest.Loader ( )
inline

The method which performs the loading of the unity WWW object.

void UnityHttp.HttpRequest.Remove ( )
inline

Removes this request from the active linked list. It won't be updated anymore.

void UnityHttp.HttpRequest.Remove ( bool  waitingList)
inline

Removes this request from a linked list.

Parameters
waitingListTrue if it should be removed from the waiting queue; false for the active queue.
void UnityHttp.HttpRequest.Send ( )
inline

Sends this request. Note that this does not block. Instead, OnRequestDone will be called when it's done.

void UnityHttp.HttpRequest.SetHeaders ( Hashtable  headers)
inline

Unavailable on Windows 8. Sets the headers using a hashtable set.

Parameters
headersThe headers to set.
void UnityHttp.HttpRequest.SetHeaders ( Dictionary< string, string >  headers)
inline

Sets the headers using a generic dictionary set.

Parameters
headersThe headers to set.
void UnityHttp.HttpRequest.SetPost ( string  toPost)
inline

Sets the PostData from the given UTF8 string.

Parameters
toPostThe string to POST.
Dictionary<string,string> UnityHttp.HttpRequest.ToDictionary ( Hashtable  headers)
inlineprivate

Converts a hashtable to a dictionary.

void UnityHttp.HttpRequest.Update ( )
inline

Advances this request by checking in on it's progress.

Member Data Documentation

object UnityHttp.HttpRequest.ExtraData

A custom object used for passing data to the callbacks.

Dictionary<string,string> UnityHttp.HttpRequest.Headers

The headers sent with this request.

IEnumerator UnityHttp.HttpRequest.LoadingEnumerator
private

The enumerator which processes the unity WWW object.

MovieTexture UnityHttp.HttpRequest.Movie

The video being downloaded, if any. Note: Pro only.

byte [] UnityHttp.HttpRequest.PostData

Post data to send with the request. See AttachForm.

bool UnityHttp.HttpRequest.Ready

True if the request is ready (but not necessarily complete).

HttpRequest UnityHttp.HttpRequest.RequestAfter

Active requests are in a linked list. The http request that follows this one.

HttpRequest UnityHttp.HttpRequest.RequestBefore

Active requests are in a linked list. The http request that is before this one.

bool UnityHttp.HttpRequest.Started

True when this request has started up.

string UnityHttp.HttpRequest.Url

The url that was requested.

WWW UnityHttp.HttpRequest.WWWRequest

The unity WWW object which performs the underlying request.

Property Documentation

byte [] UnityHttp.HttpRequest.Bytes
get

The raw bytes of the response. Null if there was an error.

string UnityHttp.HttpRequest.Error
get

The error, if any, that occured whilst attempting to load the url.

bool UnityHttp.HttpRequest.Errored
get

True if the request had an issue. PowerUI.HttpRequest.Error is the error.

Texture2D UnityHttp.HttpRequest.Image
get

The response as an image. Null if there was an error.

bool UnityHttp.HttpRequest.Ok
get

True if there was no issues.

float UnityHttp.HttpRequest.Progress
get

The current download progress.

string UnityHttp.HttpRequest.Text
get

The response as text. Empty string if there was an error.

MovieTexture UnityHttp.HttpRequest.Video
get

The response as a video. Null if there was an error.

Event Documentation

OnHttpEvent UnityHttp.HttpRequest.OnRequestDone

An event called when the request is completely finished.

OnHttpEvent UnityHttp.HttpRequest.OnRequestReady

An event called when the data is ready for use (e.g. videos).