{ "id": "160104", "key": "TIMOB-23339", "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": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2016-05-26T21:09:05.000+0000", "created": "2016-05-06T22:22:15.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "httpclient" ], "versions": [ { "id": "17707", "name": "Release 5.3.0", "archived": false, "released": true, "releaseDate": "2016-06-04" } ], "issuelinks": [], "assignee": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "updated": "2016-05-26T21:09:10.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": "This is a bug found when attempting to connect to a backend running Hunchentoot (Clisp web server), and the CLisp web framework Lucerne.\r\nMost other application servers I have experience with wouldn't mind, but this server expects to parse a request body when the Content Type is set. The Android http client, contrary to the iOS one, sets the content type not only on Post/Put/Patch as per the documentation, but actually on all http verbs.\r\nThe issue can be easily fixed by changing :\r\n\r\n{code:java}\r\nif (parts.size() > 0 && needMultipart) {\r\n\t\t\t\t\t\tboundary = HttpUrlConnectionUtils.generateBoundary();\r\n\t\t\t\t\t\tclient.setRequestProperty(\"Content-Type\", \"multipart/form-data; boundary=\" + boundary);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tclient.setRequestProperty(\"Content-Type\",\"application/x-www-form-urlencoded\");\r\n\t\t\t\t\t}\r\n{code}\r\nto \r\n\r\n{code:java}\r\nif (parts.size() > 0 && needMultipart) {\r\n\t\t\t\t\t\tboundary = HttpUrlConnectionUtils.generateBoundary();\r\n\t\t\t\t\t\tclient.setRequestProperty(\"Content-Type\", \"multipart/form-data; boundary=\" + boundary);\r\n\t\t\t\t\t} else if (isPostOrPutOrPatch){\r\n\t\t\t\t\t\tclient.setRequestProperty(\"Content-Type\",\"application/x-www-form-urlencoded\");\r\n\t\t\t\t\t}\r\n{code}\r\non itanium_mobile/android/modules/network/src/java/ti/modules/titanium/network/TiHTTPClient.java\r\n\r\nI could send a pull request if you want.\r\nCheers\r\nRichard", "attachment": [], "flagged": false, "summary": "Android http client sets the Content Type header on all requests verbs, causing some servers to time out when expecting a request body ", "creator": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "environment": null, "closedSprints": [ { "id": 627, "state": "closed", "name": "2016 Sprint 10 SDK", "startDate": "2016-05-07T00:43:56.954Z", "endDate": "2016-05-21T00:43:00.000Z", "completeDate": "2016-05-23T02:06:04.349Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "385060", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Community PR: https://github.com/appcelerator/titanium_mobile/pull/7993\r\n\r\n[~msamah] fyi", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-07T09:20:39.000+0000", "updated": "2016-05-07T09:20:58.000+0000" }, { "id": "385094", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~rlustemberg] Thanks for the PR!\r\n\r\nRight now, if you need a workaround, you can use this in your code. Hope that works for your sever.:-\r\n{code}\r\nxhr.open(\"GET\", url); \r\nxhr.setRequestHeader(\"Content-Type\", \"\");\r\nxhr.send();\r\n{code}\r\n\r\nI'm reviewing your PR and it looks good.", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-05-09T03:27:36.000+0000", "updated": "2016-05-09T03:30:01.000+0000" }, { "id": "385108", "author": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hi Ashraf.Thanks for the quick handling of the issue!\r\nThe workaround you mentioned was the first thing we tried. Nevertheless, the web framework we are using (Lucerne) won't have it. Setting the content type header itself to any value will have it expect a request body. Imho it's also a bug on the framework, but the fact remains that the http client was not abiding by the rfc. So in the end we decided to patch the SDK, as we already were maintaining a few other modifications. ", "updateAuthor": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "created": "2016-05-09T06:29:46.000+0000", "updated": "2016-05-09T06:31:13.000+0000" }, { "id": "385109", "author": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "body": "[~rlustemberg] Code reviewed and merged. https://github.com/appcelerator/titanium_mobile/pull/7993\r\nThank you!", "updateAuthor": { "name": "msamah", "key": "msamah", "displayName": "Ashraf Abu", "active": false, "timeZone": "Asia/Singapore" }, "created": "2016-05-09T06:35:50.000+0000", "updated": "2016-05-09T06:35:59.000+0000" }, { "id": "386954", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified the fix.\r\n\r\nThere are no {{403 : forbidden}} errors with the fix.\r\nClosing.\r\n\r\nEnvironment:\r\nAppc Studio : 4.6.0.201605180604\r\nTi SDK : 5.4.0.v20160526011354\r\nTi CLI : 5.0.8\r\nAlloy : 1.8.7\r\nMAC El Capitan : 10.11.4\r\nAppc NPM : 4.2.5-5\r\nAppc CLI : 5.3.0-47\r\nNode: 4.2.2\r\nNexus 6 - Android 6.0.0\r\n", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-05-26T21:07:34.000+0000", "updated": "2016-05-26T21:08:59.000+0000" }, { "id": "386955", "author": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Reopening to correct SDK version", "updateAuthor": { "name": "lchoudhary", "key": "lchoudhary", "displayName": "Lokesh Choudhary", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2016-05-26T21:08:26.000+0000", "updated": "2016-05-26T21:08:26.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }