[TIMOB-1327] setRequestHeader -> "If-Modified-Since"
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Low |
Status | Closed |
Resolution | Invalid |
Resolution Date | 2017-06-05T20:15:44.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Android |
Labels | android, base64encode, defect, if-modified-since, setrequestheader |
Reporter | marco.schierhorn (at gmail) |
Assignee | Ingo Muschenetz |
Created | 2011-04-15T02:49:29.000+0000 |
Updated | 2017-06-05T20:15:44.000+0000 |
Description
I cant use setRequestHeader with "If-Modified-Since" to get back
at 304 Status.
I want to use this for storing images and xml files on the
device.
And everytime the xml or the image is requested by the application
it should check
if a newer version is found on the server.
Im sending the date "Mon, 19 Jul 2010 11:20:22 GMT"
And im receiving the date "Mon, 19 Jul 2010 10:20:17 GMT" from the
server.
Usually it should work and return a 304 status.
if (Titanium.Network.online)
{
var c = Titanium.Network.createHTTPClient();
if (c.status == 304)
{
// XML File not necessary - Clientlog File is newer
console.log('Use Client XML File - is newer than the server XML');
fn_end(file_obj);
return;
}
// ...here will follow some code to store the files on the device
c.open('GET', url);
c.setRequestHeader("If-Modified-Since", "Mon, 19 Jul 2010 11:20:22 GMT");
c.send();
}
What platform(s) are you reporting the issue on?
Hey Don,
thanks for the response.
Im reporting this issue on Android using Titanium SDK 1.3.0 and Android SDK 2.1.
Currently im only testing it on the SDK/Emulator and not on a real phone.
Since this ticket has the attention of the devs, it looks like setRequestHeader is broken under SDK 1.4.0 with iOS as well. I am having problems setting it with basically the same code as used above:
On the server side (Google App engine), I examine the headers and see that 'Authorization' isn't set. I get the same results for 'PUT' and 'POST' as well (header not set). This happens with the iPhone simulator (iOS SDK 4.0.1). About to try it out on hardware now...
I've looked at the ObjC source of it...looks very straightforward. Perhaps it is a scoping issue?
Since the original author had an Android issue, I can create a new ticket for this if necessary.
Robby
It appears that the problem has to do with setRequestHeader silently failing if there's a line break in the value parameter - which there will be in regular use of base64encode.
My suggestion is to:
a) make it possible to call base64encode with a parameter to get a result without line breaks (which otherwise will occur for large strings)
b) log an error message if the setRequestHeader function is called with a string with line breaks (or just remove the line breaks from the string)
I described the error and a workaround in greater detail here: http://developer.appcelerator.com/question/102491/bug-discovered-base64-line-breaks#182241"> http://developer.appcelerator.com/question/102491/bug-discovered-ba... , since I was too daft to find this Lighthouse site on my own.