{ "id": "168342", "key": "TIMOB-24809", "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": "19572", "description": "Important fixes for 6.1.0", "name": "Release 6.1.1", "archived": false, "released": true, "releaseDate": "2017-06-16" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2017-06-14T17:41:53.000+0000", "created": "2017-06-12T08:53:19.000+0000", "priority": { "name": "Medium", "id": "3" }, "labels": [], "versions": [ { "id": "17608", "name": "Release 6.1.0", "archived": false, "released": true, "releaseDate": "2017-05-26" } ], "issuelinks": [], "assignee": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "updated": "2017-06-15T19:02:16.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": [], "description": "When an instance of TiHTTPClient is reused for another request with a file passed in the data the contentLength is not calculated properly. The request passes but the \"onLoad\" event is not dispatched.\r\n\r\n*Test case*:\r\n\r\nClick \"Get Photos\", wait for the reponse, dismiss the alert, and then click \"Upload photo\" - the request finishes but the \"onload\" event listener is not called.\r\n\r\n{code:javascript}\r\nvar window = Ti.UI.createWindow();\r\nvar buttonUpload = Ti.UI.createButton({title:\"Upload\", top:50});\r\nvar buttonGetPhotos = Ti.UI.createButton({title:\"Get Photos\", top: 110});\r\nvar xhr = Titanium.Network.createHTTPClient({timeout:5000});\r\n \r\nvar tempF = Ti.Filesystem.getFile(Ti.Filesystem.resourcesDirectory,\"simpleTest.png\");\r\nTi.API.info(tempF);\r\n \r\nbuttonUpload.addEventListener('click', function (e) {\r\n xhr.open(\"POST\",\"https://requestb.in/zwfzmzzw\");\r\n\r\n var data_to_send = {\r\n \"file\": tempF.read(),\r\n };\r\n \r\n xhr.onload = function () {(alert(this.responseText))};\r\n xhr.send(data_to_send);\r\n});\r\n \r\nbuttonGetPhotos.addEventListener('click', function (e) { \r\n xhr.open(\"POST\",\"https://requestb.in/zwfzmzzw\");\r\n\r\n var params = {\r\n id:46\r\n };\r\n \r\n xhr.onload = function (e) {alert(this.responseText)};\r\n xhr.send(params);\r\n});\r\n \r\nwindow.add(buttonGetPhotos);\r\nwindow.add(buttonUpload);\r\nwindow.open();\r\n{code}\r\n\r\n_Another instance of requestb.in may need to be created for testing._\r\n\r\n*Console Log:*\r\n\r\n{code:console}\r\nE/TiHTTPClient: (TiHttpClient-2) [142,13649] HTTP Error (java.lang.IllegalStateException): state: 2\r\n java.lang.IllegalStateException: state: 2\r\n at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:186)\r\n at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)\r\n at com.android.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:906)\r\n at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:782)\r\n at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:463)\r\n at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)\r\n at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:521)\r\n at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)\r\n at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java)\r\n at ti.modules.titanium.network.TiHTTPClient$ClientRunnable.run(TiHTTPClient.java:1231)\r\n at java.lang.Thread.run(Thread.java:761)\r\n{code}\r\n", "attachment": [ { "id": "62636", "filename": "simpleTest.png", "author": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "created": "2017-06-12T08:54:34.000+0000", "size": 6826, "mimeType": "image/png" } ], "flagged": false, "summary": "Android: HTTPClient - \"onload\" not dispatched", "creator": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "subtasks": [], "reporter": { "name": "kreigher", "key": "kreigher", "displayName": "gianluca", "active": true, "timeZone": "Europe/Malta" }, "environment": "OS: Windows 10\r\nTitanium SDK: master\r\nDevice:Nexus 5 Emulator API 25", "comment": { "comments": [ { "id": "421718", "author": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "body": "PR(master): https://github.com/appcelerator/titanium_mobile/pull/9139\r\nPR(6_1_X): https://github.com/appcelerator/titanium_mobile/pull/9140", "updateAuthor": { "name": "ybanev", "key": "ybanev", "displayName": "Yordan Banev", "active": true, "timeZone": "Europe/Athens" }, "created": "2017-06-12T09:13:23.000+0000", "updated": "2017-06-12T09:13:23.000+0000" }, { "id": "422094", "author": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified in SDK Version 6.1.1.v20170614134051 and 6.2.0.v20170614131253. Test and other information can be found at: \r\nPR(master): https://github.com/appcelerator/titanium_mobile/pull/9139\r\nPR(6_1_X): https://github.com/appcelerator/titanium_mobile/pull/9140", "updateAuthor": { "name": "smohammed", "key": "smohammed", "displayName": "Samir Mohammed", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2017-06-15T19:02:07.000+0000", "updated": "2017-06-15T19:02:07.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }