使用Indy库,我能够使用
得到(我假设的)服务器端cookie的全文Indy
//where aCookie is TIDCookie
aCookie.ServerCookie
结果
JSESSIONID=0000R4m1zWweo-8aSDkqoxnrccv:18seb6pc9; Path=/; Domain=somewebsite.com; HttpOnly; Max-Age=251929558529; Expires=Sat, 01-Jan-10000 05:59:59 GMT
根据文档,当尝试转换为TNetHTTPClient时,TCookie属性仅显示名称,值,路径,域,HTTPOnly,Expires和Secure。 TCookie.ToString仅返回上面的名称和值属性。
NetHTTPClient
//where c is a TCookie. IHTTPResponse.Cookies and TNetHttpClient.CookieManager.Cookies result in the same values
CookieText := c.Name+'='+c.Value
+'; Path='+ c.Path
+'; Domain='+ c.Domain
+'; HTTPOnly='+ BoolToStr(c.HttpOnly)
+'; Expires='+FormatDateTime('ddd, dd-mmm-yyyy hh:mm:ss',c.Expires)
+'; Secure='+BoolToStr(c.Secure);
结果
JSESSIONID=0000q1yBPMF6RpCgOrrOVMEcJfu:18seb6pc9; Path=/; Domain=somewebsite.com; HTTPOnly=-1; Expires=Sat, 30-Dec-1899 00:00:00; Secure=0
NetHTTPClient库中是否有办法确保您看到服务器 cookie的所有属性?