[TIMOB-5514] MobileWeb: Ti.Network.HTTPClient.getResponseHeader method generates an error or returns null.
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-07-01T01:15:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | MobileWeb |
Labels | n/a |
Reporter | Misha Vasko |
Assignee | Maxim Negadaylov |
Created | 2011-06-30T04:46:08.000+0000 |
Updated | 2017-03-09T20:31:39.000+0000 |
Description
Ti.Network.HTTPClient.getResponseHeader method generates an error in Google Chrome and returns null in Mozilla Firefox. It should return the response header.
How to: run test and look at console log.
var win = Titanium.UI.currentWindow;
var l = Titanium.UI.createLabel({
text:'Downloading image...',
font:{fontSize:13},
top:30,
left:10,
width:300,
color:'#888'
});
win.add(l);
var imageView = Titanium.UI.createImageView({
top:50,
left:10,
height:100,
width:125
});
win.add(imageView);
var closeButton = Ti.UI.createButton({
title:'Close Window',
height:40,
width:300,
top:160,
left:10,
font:{fontSize:20}
});
closeButton.addEventListener('click', function()
{
win.close();
});
win.add(closeButton);
var xhr = Titanium.Network.createHTTPClient();
var _url = (Ti.Platform.isBrowser)?'images/titanium_desk.png':'http://developer.appcelerator.com/assets/img/DEV_titmobile_image.png';
xhr.onload = function()
{
imageView.url = _url;
};
xhr.open('GET', _url);
console.log(xhr.getResponseHeader('Content-Length'));
// send the data
xhr.send();
For proper work you must rewrite part of code: var xhr = Titanium.Network.createHTTPClient(); var _url = (Ti.Platform.isBrowser)?'images/titanium_desk.png':'http://developer.appcelerator.com/assets/img/DEV_titmobile_image.png'; xhr.onload = function() { imageView.url = _url; }; xhr.onreadystatechange = function () { if (2 == xhr.readyState) { console.log(xhr.getResponseHeader('Last-Modified')); } } xhr.open('GET', _url); // send the data xhr.send();
Closing ticket as fixed.