setRequestHeader and If-Modified-Since doesnt reply a 304 status

21 views
Skip to first unread message

Marco Schierhorn

unread,
Jul 26, 2010, 11:57:07 AM7/26/10
to appcelerat...@googlegroups.com
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();
}

-- 
Marco Schierhorn
-------------------------
Tannenstrasse 51
40476 Duesseldorf | Germany 

Mobil: +49 173  / 993 7000
Fax.   +49 3212 / 103 57 13

donthorp

unread,
Jul 26, 2010, 7:40:25 PM7/26/10
to Appcelerator Titanium
Marco,

We don't use this group for support. It'd be best to move it over to
the Q&A section at http://developer.appcelerator.com

The status code won't until you call send(). You could then check the
status in your readyStateChange handler.

On Jul 26, 10:57 am, Marco Schierhorn
<marco.schierh...@googlemail.com> wrote:
> 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
>
Reply all
Reply to author
Forward
0 new messages