farshadmohajeri / extpascal

Automatically exported from code.google.com/p/extpascal
49 stars 28 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
# 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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago
Hi Xiong,

This patch works with FPC 2.4?

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

GoogleCodeExporter commented 9 years ago
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

GoogleCodeExporter commented 9 years ago

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

GoogleCodeExporter commented 9 years ago

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