为什么 LoadFromStream 在 TIdHTTP.Get 之后不显示任何内容?
我刚刚开始遇到印地问题。由于某些奇怪的原因,即使这个非常基本的过程也不起作用:
procedure TForm1.Button1Click(Sender: TObject);
var ID: TIdHTTP;
ms: TMemoryStream;
begin
ID:=TIdHTTP.Create();
ms:=TMemoryStream.Create;
ID.HandleRedirects:=true;
ID.Get('http://www.google.com',ms);
Memo1.Lines.LoadFromStream(ms);
end;
Memo1 中没有添加任何内容。 SizeOf(ms) 返回 4。
我什至重新安装了 Indy,仍然没有任何结果。我的项目以前确实有效,但现在不从任何页面下载任何内容。我想知道,问题出在哪里?
I just began having problems with Indy. For some weird reason, even this very basic procedure doesn't work:
procedure TForm1.Button1Click(Sender: TObject);
var ID: TIdHTTP;
ms: TMemoryStream;
begin
ID:=TIdHTTP.Create();
ms:=TMemoryStream.Create;
ID.HandleRedirects:=true;
ID.Get('http://www.google.com',ms);
Memo1.Lines.LoadFromStream(ms);
end;
Nothing gets added to the Memo1. SizeOf(ms) returns 4.
I even reinstalled Indy, still nothing. My project definitely worked before, but doesn't download anything from any page now. I wonder, what is the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
调用
也尝试之前
,可以通过调用“Size”属性来找出流的大小,如下所示
try calling
before
also, the size of the stream can be found out by invoking the "Size" property like so
奇怪的是,假设类似的代码以前可以工作,那么该代码应该可以工作。
抱歉,但我不得不问:
您是否确认可以在浏览器中使用同一个用户帐户从同一台计算机访问同一个 URL?尝试使用第三方浏览器和 IE。暂时无法回忆起 Indy 是否使用 WinHTTP,但有可能,影响 WinHTTP 的问题(例如某些恶意软件或 BHO)会影响 IE,但不会影响 Firefox、Chrome 或 Opera 等。
您是否尝试过关闭防病毒系统和/或防火墙(是否应该使用任何非内置防火墙)?许多防病毒软件包包括用于实时网络流量扫描的 Winsock LSP 或 NDIS 拦截器,并且可能会产生干扰。
最后,如果这一切都失败了,您能否尝试使用 Windows 端口 获取完全相同的 URL wget 或 cURL,只是为了查看是否有其他非浏览器 HTTP 客户端也表现出问题吗?
Odd, that code should work, assuming similar code worked before.
Sorry, but I have to ask:
Have you confirmed that accessing that very same URL from that very same machine under that very same user account works from within a browser? Try both a third party browser as well as IE. Can't recall offhand whether Indy uses WinHTTP but it's possible, and a problem affecting WinHTTP such as some piece of malicious software or a BHO will affect IE but won't affect, for example, Firefox, Chrome or Opera.
Have you tried turning off your antivirus system and/or your firewall (should you use any non-builtin firewall)? Many antivirus packages include Winsock LSPs or NDIS interceptors for realtime network traffic scanning and might interfere.
Finally, failing all that, can you try to fetch that very same URL using a Windows port of wget or cURL, just to see if other non-browser HTTP clients exhibit issues as well?