[TIMOB-15871] HTTPClient: setting autoRedirect off for 302s on Android calls onerror
GitHub Issue | n/a |
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2014-08-29T00:18:08.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 3.4.0 |
Components | Android |
Labels | alloy, android, error, httpclient, module_network, onerror, qe-manualtest, qe-testadded, redirect |
Reporter | Adam Lynch |
Assignee | Allen Yeung |
Created | 2013-11-13T11:35:53.000+0000 |
Updated | 2014-10-14T23:20:44.000+0000 |
Description
If you set httpclient.autoRedirect to false and then send a GET which returns a 302 (or anything but a 200 I'm guessing), then onerror is called instead of onload.
1. 301, 302, etc. responses shouldn't be deemed an error, but if you're really set on that:
2. Make it consistent. On iOS, onload is called and on Android, onerror is called. Even if you don't, at least...
3. Give us all the information. Provide more than {error:'...'} to onerror. Give us the headers, the status, the responseText, responseData, etc. if they're there in the response.
This really reduces confidence in what you're doing and requires so much more testing.
Attachments
Hello Adam! Do you have any test case that shows this issue? TIA! Best, Mauro
Hello, We have tested this issue with my test code. I got this problem. But we checked on iOS then its return success alert message.
Testing environment:
OS: MAC OS X 10.8.5 Ti SDK: 3.1.3 GA Ti CLI: 3.2.0 Android SDK 4.2.2 Device Android SDK 4.0.3 in EmulatorMy test code
Step to reproduces
1. Create a new project 2. Paste test code in app.js 3. Now run on android device/emulator 4. Click on button its return error ThanksHi I have exactly the same problem, but the problem occurs when the header code is 302 or 301 which are redirecting. And android is only in the case of self-identification does not recover or cookie. Please any solution. regards
This is really a bit poor IMHO. Correctly responding to the http specification would seem to be the most basic requirement for any http implementation, especially in mobile. I just saw http://developer.appcelerator.com/question/176965/incorrect-status-returned-by-the-http-client-in-the-330-sdk and in the tests I describe there it seems Android is in a right mess. I was wondering why this is a 'low' priority ?
Yes this should be an extremely high priority. Please fix asap - this bug has hosed critical features of my app. I can confirm that the above code sample also returns a "200" instead of a "301" when pointed to the URL of "http://google.co.nz" using the 3.3.0 SDK. Switching back to the 3.2.3 SDK fixed the issue. I am using OS X Yosemite, with Xcode 5.1.1, iOS Simulator 7.1. Interesting that this ticket was created in a much older environment. This ticket is a likely duplicate of TC-4562 just added.
The description of this ticket refers to "onerror" being called. Is that just the side effect of the wrong response code being returned? Note that this would not explain it working in 3.2.3 and not in 3.3.0. I'm not sure TC-4562 is a duplicate.
Issue can be reproduced on 3.2.3.GA and 3.3.0.GA. Due to TIMOB-17566 setting the autoRedirect in createHTTPClient() to false does not work and it defaults to true, therefore .status was always returning 200 instead of 302. This caused difficulties in being able to reproduce the issue and therefore the workaround of setting the properties via:
was used. After using the workaround I was able to reproduce the issue using the workaroundApp.js I have attached to the ticket. Tested on: Mac OSX 10.9.4 Appcelerator Studio, build: 3.4.0.201408270900 Titanium SDK build: 3.3.0.GA, 3.2.3.GA Titanium CLI, build: 3.3.0 Alloy: 1.3.1
https://github.com/appcelerator/titanium_mobile/pull/5997
Test case:
Verified the fix. Onload is called instead of onerror. Closing The response for the test case above is:
Environment: Appc Studio : 3.4.0.201408291834 Ti SDK : 3.4.0.v20140829184521 Mac OSX : 10.9.4 Alloy : 1.5.0-dev CLI - 3.4.0-dev Code Processor: 1.1.1 Nexus - android 4.2.2