IDHTTP能直接打开IE吗
czkun 2010-08-12 11:16:28 IDHTTP能直接打开IE吗,我直接post用户名和密码后,直接调用IE打开网站的后台
procedure TForm1.btnLoginClick(Sender: TObject);
var
s, s1: TStringStream;
i: Integer;
begin
s := TStringStream.Create( ' ');
s1 := TStringStream.Create( ' ');
//http.HandleRedirects:=False;
//http.OnRedirect:=MyRedirect;
http.HandleRedirects:=true;
http.HTTPOptions:=http.HTTPOptions+[hoKeepOrigProtocol];//关键这行
// http.ProtocolVersion:=pv1_1;
http.Request.ContentType:='application/x-www-form-urlencoded';
try
s.WriteString( 'name= ' + edtUserName.Text + '& ');
s.WriteString( 'email= ' + edtPassword.Text);
http.Request.ContentType := 'application/x-www-form-urlencoded ';
try
http.Post( 'http://10.241.96.17/aa.asp ', s, s1);
except
http.Get(http.Response.Location, s1);
end;
http.Request.Referer:='http://10.241.96.17/aa.asp';
http.HandleRedirects:=true;
//}
Memo1.Lines.Text := s1.DataString;
//下面的是显示cookies信息的代码
Cookies.Clear;
Cookies.Lines.Add(inttostr(CookieManager.CookieCollection.Count));
for i := 0 to CookieManager.CookieCollection.Count - 1 do
Cookies.Lines.Add(CookieManager.CookieCollection.Items[i].CookieText);
finally
s.Free;
s1.Free;
end;
end;