[TIMOB-126] HTTPClient status appears to be incorrect
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:52:05.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 0.8.0 |
Components | iOS |
Labels | network |
Reporter | jeff.larkin (at gmail) |
Assignee | Reggie Seagraves |
Created | 2011-04-15T02:24:02.000+0000 |
Updated | 2011-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
- Jeff Haynie 2011-04-15
is this for iphone, android or both?
- Jeff Haynie 2011-04-15
this has been fixed for iphone but still wrong on android.
- 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...