Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5514] MobileWeb: Ti.Network.HTTPClient.getResponseHeader method generates an error or returns null.

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2011-07-01T01:15:31.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsMobileWeb
Labelsn/a
ReporterMisha Vasko
AssigneeMaxim Negadaylov
Created2011-06-30T04:46:08.000+0000
Updated2017-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();

Comments

  1. Maxim Negadaylov 2011-07-01

    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();
  2. Lee Morris 2017-03-09

    Closing ticket as fixed.

JSON Source