indy组件idhttp用post返回response的例子,DELPHI7,INDY10运行通过
作者:高原 日期:2008-02-26
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
IdHTTP1: TIdHTTP;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
LoginInfo:TStrings;
Response:TStringStream;
i:Integer;
Cookie:string;
begin
Cookie:='';
Response := TStringStream.Create('');
LoginInfo := TStringList.Create;
try
LoginInfo.Clear;
LoginInfo.Add('ip='+trim(form1.Edit1.Text));
//IdHTTP1.Request.Referer:='http://ip.987654.com/index.asp';
//IdHTTP1.Request.From :='http://ip.987654.com/index.asp';
try
IdHTTP1.Post('http://ip.987654.com/index.asp',LoginInfo,Response);
except
showmessage('登陆失败');
end;
showmessage(Response.DataString); //从返回的页面中找出cookie
finally
LoginInfo.Free;
Response.Free;
end;
end;
end.
上一篇
下一篇

文章来自:
Tags: