{ "id": "154169", "key": "TIMOB-20219", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "17706", "name": "Release 5.4.0", "archived": false, "released": true, "releaseDate": "2016-08-11" } ], "resolution": { "id": "3", "description": "The problem is a duplicate of an existing issue.", "name": "Duplicate" }, "resolutiondate": "2016-02-11T00:00:56.000+0000", "created": "2016-01-07T20:31:03.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [ "redirect" ], "versions": [], "issuelinks": [ { "id": "50562", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "outwardIssue": { "id": "105546", "key": "TIMOB-11863", "fields": { "summary": "Imageview does not display images if URL has redirects", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "52786", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "163416", "key": "AC-4502", "fields": { "summary": "Issue TIMOB 20219 isn't fixed", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } }, { "id": "50254", "type": { "id": "10003", "name": "Relates", "inward": "relates to", "outward": "relates to" }, "inwardIssue": { "id": "105546", "key": "TIMOB-11863", "fields": { "summary": "Imageview does not display images if URL has redirects", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "High", "id": "2" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2016-09-23T18:07:47.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "If the request url is from http redirected to https, HTTPClient downloads garbage instead. On iOS it's working fine.\r\n\r\nIn the following example, http://audio.forerunner.cc/test.pdf is permanently redirected to https://audio.forerunner.cc/test.pdf\r\n\r\nExamine the downloaded file and see it's just garbage. Replace the url with https://audio.forerunner.cc/test.pdf. It will then download the file correctly.\r\n\r\nindex.js\r\n{code}\r\nvar opt = {url:'http://audio.forerunner.cc/test.pdf',type:'GET',file:Ti.Filesystem.getFile(Ti.Filesystem.tempDirectory,'test.pdf')};\r\nrequire('http').request(opt);\r\n{code}\r\n\r\n\r\nhttp.js\r\n{code}\r\nexports.request = function(opts) {\r\n\r\n\tvar xhr = Ti.Network.createHTTPClient();\r\n\r\n\txhr.timeout = (opts.timeout) ? opts.timeout : 5000;\r\n\r\n\txhr.enableKeepAlive = (opts.keepAlive) ? opts.keepAlive : false;\r\n\r\n\txhr.onload = function() {\r\n\t\tif(opts.file && OS_IOS) opts.file.remoteBackup = false; \r\n var data = (opts.format === 'json') ? JSON.parse(this.responseText) : this.responseData;\r\n var rHeader = opts.rHeader ? this.getResponseHeader(opts.rHeader) : null;\r\n if((data || rHeader) && opts.callback)\r\n\t\t\topts.callback(data, rHeader);\r\n\t};\r\n\r\n\tif (opts.ondatastream)\r\n\t\txhr.ondatastream = function(e){\r\n\t\t\topts.ondatastream(e.progress);\r\n\t\t};\r\n\r\n \r\n\txhr.onerror = function() {\r\n\t\tif(opts.file)\r\n\t\t\topts.file.deleteFile();\r\n\t\tif(opts.onerror)\r\n\t\t\topts.onerror();\r\n\t};\r\n\r\n\txhr.open(opts.type?opts.type:'GET', encodeURI(opts.url));\r\n\tif(opts.file) xhr.file = OS_ANDROID?opts.file.nativePath:opts.file;\r\n if(opts.headers) {\r\n for(var i = 0, j = opts.headers.length; i < j; i++) {\r\n xhr.setRequestHeader( opts.headers[i].name, opts.headers[i].value );\r\n }\r\n }\r\n\r\n if(opts.data) {\r\n xhr.send(JSON.stringify(opts.data));\r\n\t} else {\r\n\t\txhr.send(null);\r\n\t}\r\n};\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: HTTPClient not working with http redirected to https", "creator": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "shawnlan", "key": "shawnlan", "displayName": "Shawn Lan", "active": true, "timeZone": "America/Los_Angeles" }, "environment": "SDK 5.1.1, Android 5", "closedSprints": [ { "id": 580, "state": "closed", "name": "2016 Sprint 3 SDK", "startDate": "2016-01-30T01:31:48.991Z", "endDate": "2016-02-13T01:31:00.000Z", "completeDate": "2016-02-15T05:32:40.725Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "382285", "author": { "name": "parween.singh15@gmail.com", "key": "parween.singh15@gmail.com", "displayName": "Parween Singh", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Even, We are facing the same issue. With ti 4.0.0 sdk, it works fine both on iOS and Android. But with 5.1.1 ,It doesn't work on android. We get a garbage file downloaded, and pdf viewer gives a message \"This Document cannot be opened\". Same result when we try to download .xls file. Kindly , provide a workaround with this sdk. Thanks.", "updateAuthor": { "name": "parween.singh15@gmail.com", "key": "parween.singh15@gmail.com", "displayName": "Parween Singh", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-04-11T06:53:05.000+0000", "updated": "2016-04-11T06:53:05.000+0000" }, { "id": "389052", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Closing as duplicate & the original ticket is closed.", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-06-24T20:22:47.000+0000", "updated": "2016-06-24T20:22:47.000+0000" } ], "maxResults": 3, "total": 3, "startAt": 0 } } }