Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8612] iOS: Problem getting responseText/headers from onerror response

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionCannot Reproduce
Resolution Date2019-04-08T16:19:38.000+0000
Affected Version/sRelease 2.0.0, Release 1.8.2, Release 3.2.0, Release 3.2.1
Fix Version/sn/a
ComponentsiOS
Labelsapi, supportTeam
ReporterVarun Joshi
AssigneeUnknown
Created2012-04-09T09:08:39.000+0000
Updated2019-04-08T16:19:38.000+0000

Description

Problem

The HTTPClient does not seem to be able to get the responseText/headers from the server in onerror response(the console shows everything I print in the example below as null).

Code

{noformat} var xhr = Titanium.Network.createHTTPClient({ 'timeout': 5000 }); xhr.onerror = function() { if (this.status == 401) { //auth challenge required var guid = xhr.getResponseHeader('X-Challenge-GUID'); Titanium.API.info('Server gave GUID challenge of: "' + guid + '"'); Titanium.API.info('TEST FOO: ' + xhr.getResponseHeader('X-Custom-Header')); Titanium.API.info('TEST BAR: ' + this.getResponseHeader('Cache-Control')); Titanium.API.info('TEST BLA: ' + xhr.responseText); Titanium.API.info('TEST BOO: ' + this.responseText); } } xhr.open("GET", url); xhr.send(); {noformat} The getResponseHeader is responding as null. The onload method works fine but on trying to get the data from onerror "null" is returned.

Related Community Ticket

http://developer.appcelerator.com/question/50501/problem-getting-responsetextheaders-from-error-response

Comments

  1. Alan Hutton 2019-04-08

    Not reproducible. The code missing a statement, no URL set. Website will return a 401 error and then set the url to that and then run.

JSON Source