Delphi - '日期编码的参数无效',因为Value ['Expires'] = - 1

时间:2013-11-22 15:24:00

标签: delphi http-headers indy

我一直在使用delphi的应用程序,其中应用程序需要连接像“example.example.ex”这样的URL。

当我调用函数IdHTTP1.Post时,日期enconding过程中发生错误。

当应用程序获取连接头的某些值时,“Expires”为-1,而内部使用function RawStrInternetToDateTime(var Value: string): TDateTime;的函数EncodeDate(Year, Month, Day);无法使用值' -1' 。

我是否需要直接将“exemple.exemple.ex”,“expires”值更改为其他某个日期时间值?

1 个答案:

答案 0 :(得分:8)

正如所描述的here,Indy版本< 10不要正确处理“-1”。这就是Indy 10处理“Expires”字段的方式:

// RLebeau 01/23/2006 - IIS fix
lValue := Values['Expires']; {do not localize}
if IsNumeric(lValue) then
begin
    // This is happening when expires is an integer number in seconds
    LSecs := Sys.StrToInt(lValue);
    // RLebeau 01/23/2005 - IIS sometimes sends an 'Expires: -1' header
    if LSecs >= 0 then begin
        FExpires := Sys.Now + (LSecs / SecsPerDay);
    end else begin
        FExpires := 0.0;
    end;
end else
begin
    FExpires := GMTToLocalDateTime(lValue);
end;

正如您所看到的,如果最初为< = 0,则该值设置为0,因此如果您使用的是旧版本的Indy,则必须手动执行此操作。

相关问题