Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15854] iOS: HTTPClient returns null as responseText when location updated on page redirects

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2014-07-22T19:52:11.000+0000
Affected Version/sRelease 3.2.0, Release 3.2.3
Fix Version/sn/a
ComponentsiOS
Labelsqe-3.2.0, qe-3.2.3, qe-3.3.0
ReporterPriya Agarwal
AssigneeVishal Duggal
Created2013-12-02T11:13:56.000+0000
Updated2017-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

FileDateSize
expected.png2014-04-08T23:31:30.000+00002375010

Comments

  1. Wilson Luu 2014-04-08

    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)
  2. Pedro Enrique 2014-04-08

    Marking as invalid. The url provided redirects to another url with empty content. There is no response text or response data.
  3. Wilson Luu 2014-04-08

    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.
  4. Wilson Luu 2014-04-09

    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:
       D/TiAPI   ( 8208):  event.js -> android video check -> received text: #EXTM3U
       D/TiAPI   ( 8208):  event.js -> location: http://vod.nfhsnetwork.com/63871-VNSshf/63871.m3u8
       D/TiAPI   ( 8208):  event.js -> headers: Content-Type:application/vnd.apple.mpegurl
       
    In Xcode console, you will get this:
       event.js -> android video check -> received text: null
       event.js -> location: http://vod.nfhsnetwork.com/63871-VNSshf/63871.m3u8
       event.js -> headers: undefined
       
  5. Vishal Duggal 2014-07-22

    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.
       onredirect : function(e) {
               Ti.API.debug("redirect location -> " + this.location);
               Ti.API.debug("redirect connectionType-> " + this.connectionType);
               Ti.API.debug("redirect status-> " + this.status);
               //alert('Unable to play video.');
           },
       
  6. Lee Morris 2017-03-29

    Closing ticket as invalid.

JSON Source