Problem Description
When following the location header of a 302 FOUND redirect, an already URL encoded URL is then encoded again (for example the value %3D becomes %253D as the percent sign is URL encoded). This does not happen on 1.7.5 SDK, only 1.8.0.1 and 1.8.1
Actual Results
the URL being reencoded
Expected REsults
if the URL is encoded, don't reencode.
Test Case
*Example*
1. xhr request is made to
http://www.dropbox.com/u/18787705/app%3Dlogo.jpeg
2. Response is 302 FOUND with location header of
http://dl-web.dropbox.com/u/18787705/app%3Dlogo.jpeg
3. Under 1.8 SDK a request is then made to
http://dl-web.dropbox.com/u/18787705/app%253Dlogo.jpeg (note how the % is encoded to %25)
4. A 404 is returned as this evaluates to a filename of "app%3Dlogo.jpeg" instead of "app=logo.jpeg" as expected
The sample code below shows that this is a problem both with HTTPClient object as well as the remote image property of imageviews (toggle the makeXhrRequest variable to try both ways). The following successfully returns an image both ways under 1.7.5 SDK
var makeXhrRequest = false;
var win = Titanium.UI.createWindow();
var img = Ti.UI.createImageView();
if(makeXhrRequest){
var xhr = Titanium.Network.createHTTPClient();
xhr.onload = function() {
img.image = this.responseData;
};
xhr.open("GET", 'http://www.dropbox.com/u/18787705/app%3Dlogo.jpeg');
xhr.send();
} else {
img.image = 'http://www.dropbox.com/u/18787705/app%3Dlogo.jpeg';
}
win.add(img);
win.open();
Just tested in 1.8.2 SDK and the problem persists. This problem is forcing me to stick to 1.7.5
Tested with 2.0.1GA2 on the iOS simulator, issue still exists. Seems to work fine on Android.
Tested with 2.1.2GA and problem still exists both in iOS simulator and Device. For me however it used to work also in versions up to 1.8.2 but during that period I used a rather low iOS SDK instead: 4.3. Now with a brandnew computer, 2.1.2GA and iOS SDK 6.0 I also face this problem/bug. My workaround is by rawurlencoding the 'URL to 302 to' serverside before the actual header: 'Location' is returned to the xhr/client. But I think that's suboptimal. More comments at https://developer.appcelerator.com/question/132556/improper-url-encoding-for-302-found-on-18
*
This issue is out of date with our current supported SDK release (7.5.2.GA as of the date of closure), and out of date with mobile OS versions. If community members feel that the issue is still valid, please create a new ticket. Please reference this closed ticket number, include SDK used, comments, and code that demonstrates/reproduces the issue.