procedure TForm1.Button1Click(Sender: TObject);
var
pageStr: string;
begin
with IdHTTP1.Request do begin
IdHTTP1.HandleRedirects := true; //使用Idhttp.Post时,出现 HTTP/1.1 302 FOUND 错误,地址自动转向。
ContentType := 'application/x-www-form-urlencoded';
UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)';
end;
try
pageStr:=IdHttp1.Get('http://www.renyuansoft.com');
except
Showmessage('Network Error!');
Exit;
end;
Memo1.text := pageStr;
end;
var
pageStr: string;
begin
with IdHTTP1.Request do begin
IdHTTP1.HandleRedirects := true; //使用Idhttp.Post时,出现 HTTP/1.1 302 FOUND 错误,地址自动转向。
ContentType := 'application/x-www-form-urlencoded';
UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)';
end;
try
pageStr:=IdHttp1.Get('http://www.renyuansoft.com');
except
Showmessage('Network Error!');
Exit;
end;
Memo1.text := pageStr;
end;

本文介绍了使用IdHTTP1进行HTTP请求的基本操作,并详细解释了如何处理网络错误,包括使用IdHTTP1获取网页内容时遇到的HTTP/1.1302 FOUND错误,以及相应的错误处理机制。

802

被折叠的 条评论
为什么被折叠?



