farshadmohajeri/extpascal

TIdWebSession.TryToServeFile failed to return 304 Not Modified, fix supplied.

Closed this issue · 5 comments

# What steps will reproduce the problem?

0. You can not reproduce this if you are in GMT+0 (I'm in GMT+8) timezone
1. Compile ExtPascalSamples in indy WebServer mode
2. Open firefox to locate to the home page
3. Open firebug, navigate to the "Net" panel
4. Refresh current home page several times (say 3 times)
5. Watch the "Net" panel

# What is the expected output? What do you see instead?

It is supposed to see the "304 Not Modified" as the Status column for those
image files and css/js files.

I see "200 OK" as the Status column for those files, cached files not used.

# What version of the product are you using? On what operating system?

- extPascal: rev.HEAD
- extJS: v.3.2.1
- compiler: Delphi
- OSes: Win Vista

# Please provide any additional information below.

This but is related to GMT. Current implementation will compare the local
file date of the requested file with the requested file date.
Unfortunately, the requested file date is a GMT time, but the local file
date is retrieved as a locale time.

# How to fix this bug.

Just replace this line in TIdWebSession.TryToServeFile.CheckIfFileIsModified
  FFileDateTime := FileDateToDateTime(FileAge(FileName));
with
  FFileDateTime := GetGMTDateByName(FileName);
and it's done.

# Side effect of this fix.

This will also suppress the compiler warning says the FileAge function is
deprecated :)

Original issue reported on code.google.com by mophy...@gmail.com on 28 May 2010 at 2:02

Remember to replace another "FileDateToDateTime(FileAge(FileName));" with
"GetGMTDateByName(FileName);" in the TIdWebSession.TryToServeFile :)

Original comment by mophy...@gmail.com on 28 May 2010 at 2:13

Hi Xiong,

This patch works with FPC 2.4?

Original comment by wanderla...@gmail.com on 28 May 2010 at 2:15

  • Changed state: Accepted
I'm not sure, but it ought to: the GetGMTDateByName is an indy utility, and I 
saw
Win32/Unix detects in it's implementation.

Original comment by mophy...@gmail.com on 28 May 2010 at 2:21

Original comment by wanderla...@gmail.com on 28 May 2010 at 12:07

  • Changed state: Started

Original comment by wanderla...@gmail.com on 28 May 2010 at 1:06

  • Changed state: Fixed