cocos2d/cocos2d-x — pull request #2561 by casarock (2013-05-14 12:17:45+00:00)
Title: XMLHttpRequest as a Javascript Binding

Hi,

This pull request adds a Javascript Binding for Spidermonkey to be able to use a basic XMLHttpRequest.

Therefore I had to extend *CCHttpClient* and *CCHttpResponse* to be able to get raw header data.

The whole code is heavily inspired by https://github.com/funkaster/FakeWebGL/blob/master/FakeWebGL/WebGL/XMLHTTPRequest.cpp by Rolando Abarca

We have a implementation of Cocos2d-DragonJS which is able to use a JS API which makes heavy use of XHR.

### XMLHttpRequest is currently supporting this methods:

open - Opens a new XMLHttpRequest
send - Send a XHR.
setRequestHeader - Set custom Request header
getAllResponseHeaders - Retrieve all Header
getResponseHeader - Get a specific header

### XMLHttpRequest is currently supporting this properties:

responseText - The raw response
statusText - HTTP response status (e.g 200 ok) taken from response headers
status - Statuscode of last request.
readyState - Getter of current ready state.
withCredentials - getter and setter implemented
responseType - getter
response - response as guessed by responsetype. Fallback to raw text.
onreadystatechange - take a callback function and is being invoke when readystate changes.

### Currently unsupported and only added for compatibility:

abort() - Abort an xhr

#### Properties:
responseXML - returns NULL at the moment.
responseType - Returns an empty String
timeout - takes a value and stores it. Currently it is not set at CCHttpRequest as there is no setter implemented. The requests use defaults as set in CCHttpRequest.
upload - returns NULL and does not store anything.