[twsocket] RFC1123_Date

2012-04-25 Thread ROQUES Guillaume

Hi everyone,

I used the RFC1123_Date function in OverbyteIcsHttpSrv.pas to make 
header content (as Date, Cache control) but when I searched for it I 
found 2 lines that I don't understand.


In THttpConnection.AnswerStreamAcceptRange :
PutStringInSendBuffer ('Last-Modified: ' + RFC1123_Date(FLastModified) + 
' GMT' + #13#10);


and in THttpConnection.SendDocument(const CustomHeaders : String) :
Header := Header +  'Last-Modified: ' + RFC1123_Date(FLastModified) + ' 
GMT' + #13#10;


'GMT' is always displayed, but is it really the time on the computer 
that execute the soft ? Maybe I missed something that's why I ask you 
all


;)
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] RFC1123_Date

2012-04-25 Thread Angus Robertson - Magenta Systems Ltd
 and in THttpConnection.SendDocument(const CustomHeaders : String) :
 Header := Header +  'Last-Modified: ' + RFC1123_Date(FLastModified) 
 + ' GMT' + #13#10;
 
 'GMT' is always displayed, but is it really the time on the 
 computer that execute the soft ? Maybe I missed something that's 
 why I ask you all

These lines are all correct, the Last-Modified: header should always be
displayed time as GMT or UTC, which is the file time stamp used by
Windows since NT.  

However, there is a bug in OverbyteIcsHttpSrv.pas in function FileDate
which is returning the local time stamp of the file, not the GMT/UTC time
stamp.  I'll fix it next week.  

Angus

--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] RFC1123_Date

2012-04-25 Thread RTT



Last-Modified: header should always be displayed time as GMT or UTC


Not an HTTP imposition.  As long it's a valid http-date, it's fine. 
There is only the need to use the same convention when sending, and 
comparing these dates.





However, there is a bug in OverbyteIcsHttpSrv.pas in function FileDate
which is returning the local time stamp of the file, not the GMT/UTC time
stamp.  I'll fix it next week.


Yep. Just change the line
Result := _FileDateToDateTime(SearchRec.Time);
to
Result := 
_FileDateToDateTime(SearchRec.FindData.ftLastWriteTime);




--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] RFC1123_Date

2012-04-25 Thread RTT



Yep. Just change the line
Result := _FileDateToDateTime(SearchRec.Time);
to
Result := 
_FileDateToDateTime(SearchRec.FindData.ftLastWriteTime); 


The correct fix should be
Result := 
_FileDateToDateTime(_FileTimeToDosDateTime(SearchRec.FindData.ftLastWriteTime));


...

function  _FileTimeToDosDateTime(ft:TFileTime):Integer;
begin
SysUtils.FileTimeToDosDateTime(ft, 
LongRec(result).Hi,LongRec(result).Lo);

end;
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] RFC1123_Date

2012-04-25 Thread Arno Garrels
 there is a bug in OverbyteIcsHttpSrv.pas in function FileDate

Here's a fix, if you confirm that it works I'll check it in soon
(borrowed from code in OverbyteIcsFtpSrvT.pas) :

function FileDate(FileName : String) : TDateTime;
var
SearchRec : TSearchRec;
Status: Integer;
{$IFDEF MSWINDOWS}
LInt64: Int64;
const
FileTimeBase = -109205.0;   // days between years 1601 and 1900
FileTimeStep: Extended = 24.0 * 60.0 * 60.0 * 1000.0 * 1000.0 * 10.0; // 
100 nsec per Day
{$ENDIF}
begin
Status := FindFirst(FileName, faAnyFile, SearchRec);
try
if Status  0 then
Result := 0
else
  {$IFDEF MSWINDOWS}
Move(SearchRec.FindData.ftLastWriteTime, LInt64, SizeOf(LInt64));
Result := (LInt64 / FileTimeStep) + FileTimeBase;
  {$ENDIF}
  {$IFDEF POSIX}
Result := OverbyteIcsUtils.IcsDateTimeToUTC(SearchRec.TimeStamp);
  {$ENDIF}
finally
FindClose(SearchRec);
end;
end;


-- 
Arno
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be