HTTPClient: broken and missing functionality
The documentation for HTTPClient says: "This object (mostly) implements the XMLHttpRequest specification". However, compared to the standard XMLHttpRequest implementations it has two big problems:
A. getResponseHeader() doesn't work:
A lot of people got burned by this problem and there seems to be a bug filed for the issue, but it keeps getting pushed back with every new release. For most internet or cloud oriented mobile applications this is a major problem because important application information is often transfered in response headers (e.g., Amazon S3 storage or Window Azure Blob storage uses response headers to return property and metadata information).
B. getAllResponseHeaders() is not implemented at all:
This is a huge problem for internet and cloud oriented mobile applications too. In some cases it's a complete show stopper. Take Windows Azure Blob storage. Their API returns metadata in response header that you don't even know what it might be. All you know is that the metadata headers start with a known prefix. To get those metadata headers you need to be able to look at all available headers, but HTTPClient doesn't support it.
Question:
- Will issue A be fixed any time soon?
- Are there any plans to implement getAllResponseHeader()?
5 Answers
-
This is a big problem for us right now.. any news?
-
Hey Guys. I had the same problem. There is a work around for the getReponseHeader() problem here: https://appcelerator.lighthouseapp.com/projects/32238/tickets/1502-httpclient-problems-with-header-parsing-and-responsedata-in-onerror-handler
See the part by Brion on using a reference to the original object instead of 'this'. Works for me in 1.4.1.1 on OS4 on the iPad.
-
6 months later, still no implemetation of getAllResponseHeaders()…
I believe this is a very useful function, will it be implemented one day?
-
I think it works under getResponseHeaders()
var xhr = Titanium.Network.createHTTPClient(); xhr.onerror = function(e) { }; xhr.onload = function() { Ti.API.info("ERROR " + JSON.stringify(xhr.getResponseHeaders())); }; xhr.open('GET', 'http://nodejs.org/'); xhr.send({});
output
[INFO] ERROR { "Accept-Ranges":"bytes", "Server":"nginx", "Connection":"keep-alive", "Last-Modified":"Fri, 28 Jan 2011 05:14:52 GMT", "Content-Type":"text/html", "Content-Length":"8529","Date":"Wed, 02 Feb 2011 06:11:28 GMT "}
getResponseHeader()
var xhr = Titanium.Network.createHTTPClient(); xhr.onerror = function(e) { }; xhr.onload = function() { Ti.API.info("" + JSON.stringify(xhr.getResponseHeader("Last-Modified"))); }; xhr.open('GET', 'http://nodejs.org/'); xhr.send({});
output
[INFO] Fri, 28 Jan 2011 05:14:52 GMT
-
No it seems to not work under Android (but it's ok under iOS).
Message: TypeError: Cannot find function getResponseHeaders in object [Ti.Network.HTTPClient]. (file:///android_asset/ (…)
Please answer.