Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-126] HTTPClient status appears to be incorrect

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:52:05.000+0000
Affected Version/sn/a
Fix Version/sRelease 0.8.0
ComponentsiOS
Labelsnetwork
Reporterjeff.larkin (at gmail)
AssigneeReggie Seagraves
Created2011-04-15T02:24:02.000+0000
Updated2011-04-17T01:52:05.000+0000

Description

When I try to check this.status (or this.getStatus()) from within a onreadystatechange function, I always seem to get 0, although I believe that I should be getting either 200 or 401. Consider the following example using the twitter API:

$('#login').click(function()

{
  notify("Login Clicked");
  var query = "twitter.com/account/verify_credentials.json";
  var xhr = Titanium.Network.createHTTPClient();
  xhr.onreadystatechange = function(){
    if (this.readyState == 4 )
    {
      notify("Status: "+this.status);
    }
  };
  xhr.open('GET',
    "http://"+$('#username').val()+":"+$('#password').val()+"@"+query);
  xhr.send();
});

Based on the HTTPClient documentation, I'd expect to get either 200 or 401 for a status, depending on whether the authentication was successful. Judging from the JSON response, I can tell that I authenticate correctly or incorrectly for a given username or password, but the status code does not seem to reflect what twitter returns.

Thanks.

Comments

  1. Jeff Haynie 2011-04-15

    is this for iphone, android or both?

  2. Jeff Haynie 2011-04-15

    this has been fixed for iphone but still wrong on android.

  3. Don Thorp 2011-04-15

    (from [a6f6295b1efc296cad22d2710cac094d6b8c921e]) [#126 state:resolved] Added check for no header value. Was getting NPE on trying to access a header that didn't exist. http://github.com/appcelerator/titanium_mobile/commit/a6f6295b1efc296cad22d2710cac094d6b8c921e"> http://github.com/appcelerator/titanium_mobile/commit/a6f6295b1efc2...

JSON Source