Detailed Description

Represents a single http request. Follows redirections. Generally don't use this directly; instead create either an XMLHttpRequest or e.g. a DataPackage.

Inheritance diagram for PowerUI.Http.HttpRequest:
PowerUI.Http.IAbortable

Public Member Functions

 HttpRequest (ContentPackage package)
 Creates a new http request using the given package. More...
 
void Send ()
 Sends this request. Note that this does not block and is thread safe. Instead, OnRequestDone will be called when it's done. More...
 
void abort ()
 Aborts this request (IAbortable interface). 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 (float deltaTime)
 Advances this request by checking in on it's progress. More...
 

Public Attributes

int RedirectionCount
 Number of redirects. More...
 
WWW WWWRequest
 The unity WWW object which performs the underlying request. More...
 
MovieTexture Movie
 The video being downloaded, if any. Note: Pro only. More...
 
float Timeout_ =float.MaxValue
 Timeout if there is one. More...
 
float Duration
 How long this request has taken so far. 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...
 
ContentPackage Package
 The package this request originates from. More...
 

Properties

Location location [get]
 The url that was requested. More...
 
string url [get]
 The url that was requested. More...
 
string ResponseHeaderString [get]
 The response header string. More...
 
float timeout [get, set]
 Timeout in ms. Default is 0. More...
 
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 Unity error. 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...
 
string ContentType [get]
 Response content type. More...
 
- Properties inherited from PowerUI.Http.IAbortable
float timeout [get, set]
 The timeout if there is one. More...
 

Private Member Functions

void BeginRequest (string url, byte[] data, Dictionary< string, string > headers)
 
void HandleHeaders ()
 Checks if headers are available yet and handles them if they are. More...
 

Private Attributes

IEnumerator LoadingEnumerator
 The enumerator which processes the unity WWW object. More...
 
Dictionary< string, string > RequestHeaders
 The set of request headers. Pulled from the package. More...
 

Static Private Attributes

static PropertyInfo ResponseHeadersString
 HACK! Workaround for a long standing Unity bug that doesn't allow multiple SET-COOKIE headers. More...
 

Constructor & Destructor Documentation

PowerUI.Http.HttpRequest.HttpRequest ( ContentPackage  package)
inline

Creates a new http request using the given package.

Parameters
packageThe package that will receive the updates.
onDoneA method to call with the result.

Member Function Documentation

void PowerUI.Http.HttpRequest.abort ( )
inline

Aborts this request (IAbortable interface).

Implements PowerUI.Http.IAbortable.

void PowerUI.Http.HttpRequest.BeginRequest ( string  url,
byte[]  data,
Dictionary< string, string >  headers 
)
inlineprivate
void PowerUI.Http.HttpRequest.HandleHeaders ( )
inlineprivate

Checks if headers are available yet and handles them if they are.

IEnumerator PowerUI.Http.HttpRequest.Loader ( )
inline

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

void PowerUI.Http.HttpRequest.Remove ( )
inline

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

void PowerUI.Http.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 PowerUI.Http.HttpRequest.Send ( )
inline

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

void PowerUI.Http.HttpRequest.Update ( float  deltaTime)
inline

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

Member Data Documentation

float PowerUI.Http.HttpRequest.Duration

How long this request has taken so far.

IEnumerator PowerUI.Http.HttpRequest.LoadingEnumerator
private

The enumerator which processes the unity WWW object.

MovieTexture PowerUI.Http.HttpRequest.Movie

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

ContentPackage PowerUI.Http.HttpRequest.Package

The package this request originates from.

int PowerUI.Http.HttpRequest.RedirectionCount

Number of redirects.

HttpRequest PowerUI.Http.HttpRequest.RequestAfter

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

HttpRequest PowerUI.Http.HttpRequest.RequestBefore

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

Dictionary<string,string> PowerUI.Http.HttpRequest.RequestHeaders
private

The set of request headers. Pulled from the package.

PropertyInfo PowerUI.Http.HttpRequest.ResponseHeadersString
staticprivate

HACK! Workaround for a long standing Unity bug that doesn't allow multiple SET-COOKIE headers.

float PowerUI.Http.HttpRequest.Timeout_ =float.MaxValue

Timeout if there is one.

WWW PowerUI.Http.HttpRequest.WWWRequest

The unity WWW object which performs the underlying request.

Property Documentation

byte [] PowerUI.Http.HttpRequest.Bytes
get

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

string PowerUI.Http.HttpRequest.ContentType
get

Response content type.

string PowerUI.Http.HttpRequest.Error
get

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

bool PowerUI.Http.HttpRequest.Errored
get

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

Texture2D PowerUI.Http.HttpRequest.Image
get

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

Location PowerUI.Http.HttpRequest.location
get

The url that was requested.

bool PowerUI.Http.HttpRequest.Ok
get

True if there was no Unity error.

float PowerUI.Http.HttpRequest.Progress
get

The current download progress.

string PowerUI.Http.HttpRequest.ResponseHeaderString
get

The response header string.

string PowerUI.Http.HttpRequest.Text
get

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

float PowerUI.Http.HttpRequest.timeout
getset

Timeout in ms. Default is 0.

string PowerUI.Http.HttpRequest.url
get

The url that was requested.

MovieTexture PowerUI.Http.HttpRequest.Video
get

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