[TIMOB-19950] iOS: HTTP requests with basic auth returning with 401 Unauthorised trigger endless repeated requests
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2016-01-14T02:55:08.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 5.1.2 |
Components | iOS |
Labels | Community, httpclient, regression |
Reporter | Terry Morgan |
Assignee | Eric Merriman |
Created | 2015-11-11T14:27:43.000+0000 |
Updated | 2017-03-21T20:44:27.000+0000 |
Description
Making an HTTP request with basic auth that that results in a 401 response causes the same request to be repeated resulting in an endless loop of HTTP requests.
Neither onload nor onerror callback is called.
Test case:
var url = "http://httpbin.org/basic-auth/user/passwd";
var client = Ti.Network.createHTTPClient({
// function called when the response data is available
onload : function(e) {
Ti.API.info("Received text: " + this.responseText);
alert('success');
},
// function called when an error occurs, including a timeout
onerror : function(e) {
Ti.API.debug(e.error);
alert('error');
},
username: "test",
password: "test",
timeout : 5000 // in milliseconds
});
// Prepare the connection.
client.open("GET", url);
// Send the request.
client.send();
Hi , I tested the issue you reported . I can reproduce it only iPhone devices but everything worked fine on simulators. I tested this using the 5.1.0.v20151021104424. This is a valid issue. *Environment*
Thanks
I've tested this against 2 different APIs with the same result. If you're not familiar with it, http://httpbin.org is a very useful resource for testing for specific API responses and it is one of the two APIs I have tested this against (as per my test case above). This seems to be an issue specific to 401 responses so it's important you test against a real API that returns a valid "401 Unauthorized" response to reproduce this issue. I mention this as your test code appears to use a dummy url. You may have used a real API when you actually tested but I wanted to check that this was definitely the case. I also notice that you're not setting the username & password for HTTP basic auth correctly in your test case. As per the Ti does, the username & password need to be set on the XHR object before calling open(), as per my test case. http://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network.HTTPClient-property-username Finally, it's important to either monitor the requests from the API end or use a proxy to monitor traffic as there will be no output whatsoever in the Titanium logs. Would you mind either confirming that your tests complies with the above or trying again to reproduce following the above guidelines?
Same here! But only on real device (iPhone 5). Everything worked fine on simulators...that's super strange! iOS 9.1 SDK 5.0.2
Closing ticket as fixed.