我有 Indy 10.6、Windows 10 和 Delphi XE7。
在响应 HTTPS GET
请求时,CookieManager
声明不存在 cookie,但 HTTP 分析器显示存在:
HTTP/1.1 200 OK
Date: Wed, 11 Jul 2018 10:47:22 GMT
Server: Apache
Cache-Control: no-cache
Pragma: No-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
X-Frame-Options: DENY
Set-Cookie: JSESSIONID=vqf9bFgB0wp1vyznZTQ2TLGzpQbpYQTgnwqhtvQpl2D0JdsrpH8G!-32035106!wls-baap401.test.vocalink.co.uk!13129!13109; path=/; HttpOnly
Content-Type: text/xml; charset=UTF-8
Content-Length: 162
我的代码是:
html := IdHTTP1.Get(Login);
Cookies := IdCookieManager1.CookieCollection.LockCookieList(caRead);
try
for I := 0 to Cookies.Count-1 do
begin
Cookie := Cookies[I];
// save Cookie as needed...
end;
finally
IdCookieManager1.CookieCollection.UnlockCookieList(caRead);
end;
但是Cookies.Count
是0。
有什么想法吗?
最佳答案
已排序。作为 Indy 的新手,我忘记将 cookie 管理器连接到 idHTTP ! 现在代码可以正常工作了。
关于delphi - 无法从 Indy TIdCookieManager 获取 cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51283766/