idhttp get网页 出现 http/1.0 400 bad request 问题

tnianshao 2009-10-11 01:53:54
procedure TForm1.Button1Click(Sender: TObject);
var
HTTP: TidHTTP;
html, s: string;
i: integer;
begin
timer3.Enabled:=false;
HTTP := TidHTTP.Create(nil);
try
http.ReadTimeout:=3000;
http.Request.Accept := 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*';
http.Request.AcceptLanguage := 'zh-cn';
http.Request.ContentType := 'application/x-www-form-urlencoded';
http.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)';
HTTP.HandleRedirects := True;
HTTP.AllowCookies := True;
http.Request.Referer:=edit3.Text; //来路设置
http.ProxyParams.ProxyServer:= edit7.Text; //代理IP
http.ProxyParams.ProxyPort:=strtoint(TRIM(edit8.Text)); //代理端口
HTTP.Request.CustomHeaders.Values['Cookie'] := 'abcd';//修改Cookie 抓包可见
html := HTTP.Get(edit5.Text);
s := 'Cookies: ';
if HTTP.CookieManager.CookieCollection.Count > 0 then
for i := 0 to HTTP.CookieManager.CookieCollection.Count - 1 do
s := s + HTTP.CookieManager.CookieCollection.Items[i].CookieText;
Memo1.Lines.Add(s);//取得Cookie
finally
FreeAndNil(HTTP);
end;
end;


以上是 Button1的代码 其他代码检查无错

就是运行时出现 eidhttpprotocolexception with message 'http/1.0 400 bad request

如何解决 求解
...全文
1527 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
haitao 2009-10-11
  • 打赏
  • 举报
回复
那是不是这个代理要求1.0或使用了1.0?
tnianshao 2009-10-11
  • 打赏
  • 举报
回复
不使用 代理 OK 郁闷 我就是要用代理的
haitao 2009-10-11
  • 打赏
  • 举报
回复
哦,还通过代理?不使用代理直接访问会怎样?
haitao 2009-10-11
  • 打赏
  • 举报
回复
那么,是idhttp的设置有问题,它按http/1.0去访问网站了。。。。。。。
tnianshao 2009-10-11
  • 打赏
  • 举报
回复
我 get 的 百度 和 163 都这样 郁闷
haitao 2009-10-11
  • 打赏
  • 举报
回复
现在一般都是http/1.1的了,对方还是只支持1.0的服务器?

1,593

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 网络通信/分布式开发
社区管理员
  • 网络通信/分布式开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧