{ "id": "61959", "key": "TIMOB-1327", "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": [], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2017-06-05T20:15:44.000+0000", "created": "2011-04-15T02:49:29.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "base64encode", "defect", "if-modified-since", "setrequestheader" ], "versions": [], "issuelinks": [], "assignee": { "name": "ingo", "key": "ingo", "displayName": "Ingo Muschenetz", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-06-05T20:15:44.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": "{html}

I cant use setRequestHeader with \"If-Modified-Since\" to get back\nat 304 Status.
\nI want to use this for storing images and xml files on the\ndevice.
\nAnd everytime the xml or the image is requested by the application\nit should check
\nif a newer version is found on the server.
\nIm sending the date \"Mon, 19 Jul 2010 11:20:22 GMT\"
\nAnd im receiving the date \"Mon, 19 Jul 2010 10:20:17 GMT\" from the\nserver.
\nUsually it should work and return a 304 status.

\n
\n\nif (Titanium.Network.online)\n{\n      var c = Titanium.Network.createHTTPClient();\n      if (c.status == 304)\n      {\n        // XML File not necessary - Clientlog File is newer\n        console.log('Use Client XML File - is newer than the server XML');\n        fn_end(file_obj);\n        return;\n      }\n      // ...here will follow some code to store the files on the device\n\n      c.open('GET', url);\n      c.setRequestHeader(\"If-Modified-Since\", \"Mon, 19 Jul 2010 11:20:22 GMT\");\n      c.send();\n}\n
{html}", "attachment": [], "flagged": false, "summary": "setRequestHeader -> \"If-Modified-Since\"", "creator": { "name": "marco.schierhorn(atgmail)", "key": "marco.schierhorn(atgmail)", "displayName": "marco.schierhorn (at gmail)", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "marco.schierhorn(atgmail)", "key": "marco.schierhorn(atgmail)", "displayName": "marco.schierhorn (at gmail)", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "125349", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

What platform(s) are you reporting the issue on?

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:49:30.000+0000", "updated": "2011-04-15T02:49:30.000+0000" }, { "id": "125350", "author": { "name": "marco.schierhorn(atgmail)", "key": "marco.schierhorn(atgmail)", "displayName": "marco.schierhorn (at gmail)", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Hey Don,

\n

thanks for the response.
\nIm reporting this issue on Android using Titanium SDK 1.3.0 and\nAndroid SDK 2.1.
\nCurrently im only testing it on the SDK/Emulator and not on a real\nphone.

{html}", "updateAuthor": { "name": "marco.schierhorn(atgmail)", "key": "marco.schierhorn(atgmail)", "displayName": "marco.schierhorn (at gmail)", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:49:30.000+0000", "updated": "2011-04-15T02:49:30.000+0000" }, { "id": "125351", "author": { "name": "robby", "key": "robby", "displayName": "Robby", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Since this ticket has the attention of the devs, it looks like\nsetRequestHeader is broken under SDK 1.4.0 with iOS as well. I am\nhaving problems setting it with basically the same code as used\nabove:

\n
\nvar myUsername = 'testuser';\nvar myPassword = 'testpass';\n\nvar request = Titanium.Network.createHTTPClient({\n        onload:function(e) {\n            if (request.status != 200 && request.status != 201) {\n                request.onerror(e);\n                return;\n            }\n        },\n        onerror:function(e) {\n            Ti.API.info(\"Got Error: \"\n                + e.error);\n        }\n    });\n\nrequest.open('GET', 'https://myserverurl', true);\nrequest.setRequestHeader('Authorization','Basic '  + Titanium.Utils.base64encode(myUsername + ':' + myPassword));\nrequest.send();\n
\n

On the server side (Google App engine), I examine the headers\nand see that 'Authorization' isn't set. I get the same results for\n'PUT' and 'POST' as well (header not set). This happens with the\niPhone simulator (iOS SDK 4.0.1). About to try it out on hardware\nnow...

\n

I've looked at the ObjC source of it...looks very\nstraightforward. Perhaps it is a scoping issue?

\n

Since the original author had an Android issue, I can create a\nnew ticket for this if necessary.

\n

Robby

{html}", "updateAuthor": { "name": "robby", "key": "robby", "displayName": "Robby", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:49:31.000+0000", "updated": "2011-04-15T02:49:31.000+0000" }, { "id": "125352", "author": { "name": "jacobavlund", "key": "jacobavlund", "displayName": "Jacob Avlund", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

It appears that the problem has to do with setRequestHeader\nsilently failing if there's a line break in the value parameter -\nwhich there will be in regular use of base64encode.

\n

My suggestion is to:

\n

a) make it possible to call base64encode with a parameter to get\na result without line breaks (which otherwise will occur for large\nstrings)
\nb) log an error message if the setRequestHeader function is called\nwith a string with line breaks (or just remove the line breaks from\nthe string)

\n

I described the error and a workaround in greater detail here:\n\nhttp://developer.appcelerator.com/question/102491/bug-discovered-ba...\n, since I was too daft to find this Lighthouse site on my own.

{html}", "updateAuthor": { "name": "jacobavlund", "key": "jacobavlund", "displayName": "Jacob Avlund", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T02:49:32.000+0000", "updated": "2011-04-15T02:49:32.000+0000" } ], "maxResults": 4, "total": 4, "startAt": 0 } } }