[TIMOB-2383] HTTPClient doesn't trigger "onerror" with 4xx and 5xx HTTP response codes
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-10-27T15:53:51.000+0000 |
Affected Version/s | Release 1.7.0 |
Fix Version/s | Sprint 2011-32, Release 1.8.0 |
Components | iOS |
Labels | n/a |
Reporter | Vance Lucas |
Assignee | Blain Hamon |
Created | 2011-04-15T03:18:19.000+0000 |
Updated | 2011-10-27T15:53:51.000+0000 |
Description
When working with the HTTPClient, I was expecting a 404 response to trigger my "onerror" function, but it never did. Even a 500 "Internal Server Error" response did not trigger the "onerror" function. Everything I tried just executed "onload", regardless of the actual server's response.
More useful behavior would be similar to jQuery's ajax
method:
http://api.jquery.com/jQuery.ajax/">http://api.jquery.com/jQuery.ajax/
- 1xx and 2xx responses trigger the "success" callback
- 4xx and 5xx responses trigger the "error" callback
This is reproducible on android too! Associated helpdesk ticket: http://support-admin.appcelerator.com/display/9600 Increasing the customer priority to 'within release'. Ex: The 'xhr_error.js' in kitchensink demonstrates the same.
Assigning back to Ani for sample code creation.
Sample code is same as xhr_error.js in kitchensink. Have attached the same.
I shall update this ticket with the server side code by EOD!
I added an action to appc.me for testing this out. Change the "code=" to some other code (like 403, 500, etc) and the server will respond appropriately. If you look at the response sent from the server, you should also see a custom status description is getting returned as well.
WORKS properly on Android! Does not work on iPhone Simulator 4.3.
Oh Dawson has done it already:) Thanks Dawson. Yes, it works fine on Android.
Onerror is now triggered when an error is returned, but the e.error is returning undefined. Closing this bug as fixed and opened another TIMOB-5294 describing the new problem. Verified fixed with Titanium Studio, build: 1.0.5.201109091616, SDK 1.8.0.v20110914184549 on an iPad 2, 4.3.5 and iPod touch 3rd Gen 4.0.2.