IDHTTP HTTP/1.1 405
场景:idhttp登陆网站http/1.1 405异常,有代码,请高手分析
idhttp登陆网站http/1.1 405错误,有代码,请高手分析
环境是D7,用idhttp登陆19楼,报http/1.1 405错误,发的数据包貌似没有错误,想不出原因,请教大家,谢谢
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ToolWin, IdCookieManager, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, ExtCtrls;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
IdCookieManager1: TIdCookieManager;
ToolBar1: TToolBar;
LoginBtn: TButton;
ToolButton1: TToolButton;
Memo1: TMemo;
Button1: TButton;
ToolButton2: TToolButton;
Timer1: TTimer;
procedure LoginBtnClick(Sender: TObject);
procedure IdHTTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.LoginBtnClick(Sender: TObject);
var
Params:TStrings;
res:TStringStream;
Url,Cook_Str:String;
begin
IdHTTP1.ReadTimeout:= 25000;
IdHTTP1.Request.Accept:= 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
IdHTTP1.Request.AcceptEncoding:= 'gzip, deflate';
IdHTTP1.Request.AcceptLanguage:= 'zh-cn';
IdHTTP1.Request.CacheControl:= 'no-cache';
IdHTTP1.Request.Connection:= 'Keep-Alive';
IdHTTP1.Request.ContentLength:=144;
IdHTTP1.Request.ContentType:= 'application/x-www-form-urlencoded';
Cook_Str:='__utma=92551362.1470865355.1315979220.1315979220.1315979220.1; __utmz=92551362.1315979220.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);';
Cook_Str:=Cook_Str+' Hm_lvt_5185a335802fb72073721d2bb161cd94=1315979210890; __utmb=92551362.1.10.1315979220; __utmc=92551362; Hm_lpvt_5185a335802fb72073721d2bb161cd94=1315979220531; cdb_sid=7280dda0956157fb93a80c5b0f690556; BIGipServerforum_web_pool=100729098.20480.0000';
IdHTTP1.Request.CustomHeaders.Add(Cook_Str);
IdHTTP1.Request.Host:= 'passport.19lou.com';
IdHTTP1.Request.Referer:= 'http://hangzhou.19lou.com/';
IdHTTP1.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
Params :=TStringList.Create;
try
Params.Append('autoLogin=1');
Params.Append('eb0478242e3f3dbdbbf7df7566f404c1=d5520ab6f8095f0f72d4847d4b95c633');
Params.Append('login=?');
Params.Append('userName=********');
Params.Append('userPass=********');
try
Url := 'http://passport.19lou.com/login/index/t/normal';
IdHTTP1.HandleRedirects:=True;
res := TStringStream.Create('');
IdHTTP1.Post(Url,Params,res);
UTF8Decode(TStringStream(IdHTTP1.Response.ContentStream).dataString);
Memo1.Lines.Add(res.DataString);
except
end;
finally
Params.Free;
end;
end;
procedure TForm1.IdHTTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
Memo1.Lines.Add('****************************(DEBUG开始)***************************');
Memo1.Lines.Add('=======(访问页面)=========');
Memo1.Lines.Add(IdHTTP1.URL.URI);
Memo1.Lines.Add('=======(页面信息)=========');
Memo1.Lines.Add(IdHttp1.ResponseText);
Memo1.Lines.Add('=======(页面反馈)=========');
Memo1.Lines.Add('-------[发送过去的信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Request.RawHeaders);
Memo1.Lines.Add('-------[发送过去的自定义信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Request.CustomHeaders);
Memo1.Lines.Add('-------[返回回来的信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Response.RawHeaders);
Memo1.Lines.Add('-------[返回回来的自定义信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Response.CustomHeaders);
Memo1.Lines.Add('=======(页面内容)=========');
Memo1.Lines.Add(UTF8Decode(TStringStream(IdHTTP1.Response.ContentStream).dataString));
Memo1.Lines.Add('***************************(DEBUG结束)***************************');
end;
end.
------解决方案--------------------
我这里是正确的呀...没有错误!
这是GET中的代码
id="27bbbf00ef356f9e2351357dd3ef4f14" name="27bbbf00ef356f9e2351357dd3ef4f14" value="78493eb41f0cb5ca35e1bd086c0a0d34
这是用Httpanalyzerstd截获的包
POST /login/index/t/normal HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://passport.19lou.com/login/index/t/normal
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
Host: passport.19lou.com
Content-Length: 141
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: cdb_sid=d715056b6adc992137ce7b29a0e39fd6; BIGipServerforum_web_pool=83951882.20480.0000
userName=love&autoLogin=1&userPass=123456&27bbbf00ef356f9e2351357dd3ef4f14=78493eb41f0cb5ca35e1bd086c0a0d34&login=%C1%A2%BC%B4%B5%C7%C2%BC
idhttp登陆网站http/1.1 405错误,有代码,请高手分析
环境是D7,用idhttp登陆19楼,报http/1.1 405错误,发的数据包貌似没有错误,想不出原因,请教大家,谢谢
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ToolWin, IdCookieManager, IdBaseComponent,
IdComponent, IdTCPConnection, IdTCPClient, IdHTTP, ExtCtrls;
type
TForm1 = class(TForm)
IdHTTP1: TIdHTTP;
IdCookieManager1: TIdCookieManager;
ToolBar1: TToolBar;
LoginBtn: TButton;
ToolButton1: TToolButton;
Memo1: TMemo;
Button1: TButton;
ToolButton2: TToolButton;
Timer1: TTimer;
procedure LoginBtnClick(Sender: TObject);
procedure IdHTTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.LoginBtnClick(Sender: TObject);
var
Params:TStrings;
res:TStringStream;
Url,Cook_Str:String;
begin
IdHTTP1.ReadTimeout:= 25000;
IdHTTP1.Request.Accept:= 'image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*';
IdHTTP1.Request.AcceptEncoding:= 'gzip, deflate';
IdHTTP1.Request.AcceptLanguage:= 'zh-cn';
IdHTTP1.Request.CacheControl:= 'no-cache';
IdHTTP1.Request.Connection:= 'Keep-Alive';
IdHTTP1.Request.ContentLength:=144;
IdHTTP1.Request.ContentType:= 'application/x-www-form-urlencoded';
Cook_Str:='__utma=92551362.1470865355.1315979220.1315979220.1315979220.1; __utmz=92551362.1315979220.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);';
Cook_Str:=Cook_Str+' Hm_lvt_5185a335802fb72073721d2bb161cd94=1315979210890; __utmb=92551362.1.10.1315979220; __utmc=92551362; Hm_lpvt_5185a335802fb72073721d2bb161cd94=1315979220531; cdb_sid=7280dda0956157fb93a80c5b0f690556; BIGipServerforum_web_pool=100729098.20480.0000';
IdHTTP1.Request.CustomHeaders.Add(Cook_Str);
IdHTTP1.Request.Host:= 'passport.19lou.com';
IdHTTP1.Request.Referer:= 'http://hangzhou.19lou.com/';
IdHTTP1.Request.UserAgent:= 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)';
Params :=TStringList.Create;
try
Params.Append('autoLogin=1');
Params.Append('eb0478242e3f3dbdbbf7df7566f404c1=d5520ab6f8095f0f72d4847d4b95c633');
Params.Append('login=?');
Params.Append('userName=********');
Params.Append('userPass=********');
try
Url := 'http://passport.19lou.com/login/index/t/normal';
IdHTTP1.HandleRedirects:=True;
res := TStringStream.Create('');
IdHTTP1.Post(Url,Params,res);
UTF8Decode(TStringStream(IdHTTP1.Response.ContentStream).dataString);
Memo1.Lines.Add(res.DataString);
except
end;
finally
Params.Free;
end;
end;
procedure TForm1.IdHTTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
Memo1.Lines.Add('****************************(DEBUG开始)***************************');
Memo1.Lines.Add('=======(访问页面)=========');
Memo1.Lines.Add(IdHTTP1.URL.URI);
Memo1.Lines.Add('=======(页面信息)=========');
Memo1.Lines.Add(IdHttp1.ResponseText);
Memo1.Lines.Add('=======(页面反馈)=========');
Memo1.Lines.Add('-------[发送过去的信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Request.RawHeaders);
Memo1.Lines.Add('-------[发送过去的自定义信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Request.CustomHeaders);
Memo1.Lines.Add('-------[返回回来的信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Response.RawHeaders);
Memo1.Lines.Add('-------[返回回来的自定义信息]---------------');
Memo1.Lines.AddStrings(IdHTTP1.Response.CustomHeaders);
Memo1.Lines.Add('=======(页面内容)=========');
Memo1.Lines.Add(UTF8Decode(TStringStream(IdHTTP1.Response.ContentStream).dataString));
Memo1.Lines.Add('***************************(DEBUG结束)***************************');
end;
end.
------解决方案--------------------
我这里是正确的呀...没有错误!
这是GET中的代码
id="27bbbf00ef356f9e2351357dd3ef4f14" name="27bbbf00ef356f9e2351357dd3ef4f14" value="78493eb41f0cb5ca35e1bd086c0a0d34
这是用Httpanalyzerstd截获的包
POST /login/index/t/normal HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*
Referer: http://passport.19lou.com/login/index/t/normal
Accept-Language: zh-cn
Content-Type: application/x-www-form-urlencoded
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)
Host: passport.19lou.com
Content-Length: 141
Connection: Keep-Alive
Cache-Control: no-cache
Cookie: cdb_sid=d715056b6adc992137ce7b29a0e39fd6; BIGipServerforum_web_pool=83951882.20480.0000
userName=love&autoLogin=1&userPass=123456&27bbbf00ef356f9e2351357dd3ef4f14=78493eb41f0cb5ca35e1bd086c0a0d34&login=%C1%A2%BC%B4%B5%C7%C2%BC