[TIMOB-15854] iOS: HTTPClient returns null as responseText when location updated on page redirects
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2014-07-22T19:52:11.000+0000 |
Affected Version/s | Release 3.2.0, Release 3.2.3 |
Fix Version/s | n/a |
Components | iOS |
Labels | qe-3.2.0, qe-3.2.3, qe-3.3.0 |
Reporter | Priya Agarwal |
Assignee | Vishal Duggal |
Created | 2013-12-02T11:13:56.000+0000 |
Updated | 2017-03-29T21:41:16.000+0000 |
Description
HTTPClient returns null as responseText when location updated on page redirects.
var videoURL = "http://api.playonsports.com/v1/videos/65601.hls?Authorization=bearer%2051033058bb53a691ccc7df4340271f29";
var client = Ti.Network.createHTTPClient({
onload : function(e) {
Ti.API.debug("event.js -> android video check -> received text: " + this.responseText);
Ti.API.debug("event.js -> location: " + this.location);
Ti.API.debug("event.js -> headers: " + this.getAllResponseHeaders());
var win = Ti.UI.createWindow({
backgroundColor: 'green'
});
var activeMovie = Ti.Media.createVideoPlayer({
url : this.location,
backgroundColor : '#000',
mediaControlStyle : Ti.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Ti.Media.VIDEO_SCALING_ASPECT_FILL,
fullscreen : true,
autoplay : true
});
win.add(activeMovie);
win.open();
},
onerror : function(e) {
Ti.API.debug("event.js -> " + e.error);
alert('Unable to play video.');
},
timeout : 5000
});
client.open("HEAD", videoURL);
client.send();
Result:
Video is not getting played.
console log:
event.js -> android video check -> received text:null
This is not a regression as also not working for 3.1.3.GA also.
Attachments
File | Date | Size |
---|---|---|
expected.png | 2014-04-08T23:31:30.000+0000 | 2375010 |
This bug is still reproducible. this.responseText is returning undefined when testing against the master SDK build (3.3.0.v20140407144327); this.responseText returns null when tested against SDK build 3.2.3.v20140403105720. Tested on: Appcelerator Studio, build: 3.2.3.201403271839 SDK build: 3.2.3.v20140403105720, 3.3.0.v20140407144327 CLI: 3.2.3-alpha2 Alloy: 1.3.1 Xcode: 5.1 Devices: iphone 4 (7.1), iphone 5 (7.0)
Marking as invalid. The url provided redirects to another url with empty content. There is no response text or response data.
Reopening this ticket. The url provided redirects to another url, but the content is still available (see expected.png) and responseText will still return null (in SDK 3.2.3) or undefined (in SDK 3.3.0). I've updated the above sample code which will open the video player in a new window.
Also, tried the above sample code on Samsung Galaxy S3 (4.3) with SDK build 3.2.3.v20140403105720 and get this in the logcat:
In Xcode console, you will get this:
Essentially what is happening is that the request to the original URL is redirecting with a 301 Code. On Android the request is redirected with method set to GET. (no idea why) On iOS the request is redirected with the method still HEAD. Since HEAD requests have no response body, responseText and responseData will be null. iOS behavior is pretty easy to verify by adding a **undocumented onredirect callback** as shown below. Android actually has bug where it does not update the connectionType on the proxy for a redirected request.
Closing ticket as invalid.