delphi 里用 indy idhttpserver 怎么接收post过来的数据
1个回答
2016-01-25
展开全部
idhttp的post方法:
function Post(AURL: string; const ASource: TStrings): string; overload;
function Post(AURL: string; const ASource: TStream): string; overload;
function Post(AURL: string; const ASource: TIdMultiPartFormDataStream): string; overload;
procedure Post(AURL: string; const ASource: TStrings; const AResponseContent: TStream); overload;
procedure Post(AURL: string; const ASource: TStream; const AResponseContent: TStream); overload;
procedure Post(AURL: string; const ASource: TIdMultiPartFormDataStream; AResponseContent: TStream); overload;
2、异常响应为开发者提供了一个按自己的需要进行异常处理的机制。主要异常处理有两种: try except end
try finally
try …except …end形成了一个异常响应保护块。与finally不同的是:正常情况下except 后面的语句并不被执行,而当异常发生时程序自动跳到except,进入异常响应处理模块。当异常被响应后异常类自动清除。相关文章http://www.fosu.edu.cn/netschool/delphi/029.htm
主要代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Memo1: TMemo;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button1: TButton;
Button2: TButton;
Edit4: TEdit;
Label6: TLabel;
IdHTTP1: TIdHTTP;
Memo2: TMemo;
Label7: TLabel;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
mytemp:tStringList; //变量定义
sex:string;
begin
if RadioButton1.Checked=true then begin //判断性别
sex:=RadioButton1.Caption;
end;
if RadioButton2.Checked=true then begin
sex:=RadioButton2.Caption;
end;
//以下值都来自http://www.gxxezz.com/liuyan/index.asp的页面分析,分析出其中的必要的提交元素,不要忘记hidden类型的
mytemp:=tStringList.Create;
mytemp.Add('NAME='+edit1.Text);
mytemp.Add('sex='+sex);
mytemp.Add('email='+edit2.Text);
mytemp.Add('WEB='+edit3.Text);
mytemp.Add('MESSAGE='+Memo1.Lines.Text);
mytemp.Add('Send=1'); //这个是个隐藏属性,一定得加啊
try
IdHTTP1.Post('http://www.gxxezz.com/liuyan/index.asp',mytemp); //idhttp提交post请求,如果攻击其他的留言本得更换提交地址
except
Memo2.Lines.Add('估计是成功了'); //发送完毕记录
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if timer1.Enabled=false then
begin
timer1.Interval:=strtoint(Edit4.Text); //设定攻击间隔
timer1.Enabled:=true; //激活定时器
Button2.Caption:='停止攻击'; //改变按钮文字
end
else begin
timer1.Enabled:=false; //停止定时器
Button2.Caption:='自动攻击'; //改变按钮文字
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
application.ProcessMessages; //防止界面死掉
Button1Click(self); //按照设定的时间间隔自动点击发送按钮
end;
end.
function Post(AURL: string; const ASource: TStrings): string; overload;
function Post(AURL: string; const ASource: TStream): string; overload;
function Post(AURL: string; const ASource: TIdMultiPartFormDataStream): string; overload;
procedure Post(AURL: string; const ASource: TStrings; const AResponseContent: TStream); overload;
procedure Post(AURL: string; const ASource: TStream; const AResponseContent: TStream); overload;
procedure Post(AURL: string; const ASource: TIdMultiPartFormDataStream; AResponseContent: TStream); overload;
2、异常响应为开发者提供了一个按自己的需要进行异常处理的机制。主要异常处理有两种: try except end
try finally
try …except …end形成了一个异常响应保护块。与finally不同的是:正常情况下except 后面的语句并不被执行,而当异常发生时程序自动跳到except,进入异常响应处理模块。当异常被响应后异常类自动清除。相关文章http://www.fosu.edu.cn/netschool/delphi/029.htm
主要代码
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient, IdHTTP, ExtCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Memo1: TMemo;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
Button1: TButton;
Button2: TButton;
Edit4: TEdit;
Label6: TLabel;
IdHTTP1: TIdHTTP;
Memo2: TMemo;
Label7: TLabel;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
mytemp:tStringList; //变量定义
sex:string;
begin
if RadioButton1.Checked=true then begin //判断性别
sex:=RadioButton1.Caption;
end;
if RadioButton2.Checked=true then begin
sex:=RadioButton2.Caption;
end;
//以下值都来自http://www.gxxezz.com/liuyan/index.asp的页面分析,分析出其中的必要的提交元素,不要忘记hidden类型的
mytemp:=tStringList.Create;
mytemp.Add('NAME='+edit1.Text);
mytemp.Add('sex='+sex);
mytemp.Add('email='+edit2.Text);
mytemp.Add('WEB='+edit3.Text);
mytemp.Add('MESSAGE='+Memo1.Lines.Text);
mytemp.Add('Send=1'); //这个是个隐藏属性,一定得加啊
try
IdHTTP1.Post('http://www.gxxezz.com/liuyan/index.asp',mytemp); //idhttp提交post请求,如果攻击其他的留言本得更换提交地址
except
Memo2.Lines.Add('估计是成功了'); //发送完毕记录
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if timer1.Enabled=false then
begin
timer1.Interval:=strtoint(Edit4.Text); //设定攻击间隔
timer1.Enabled:=true; //激活定时器
Button2.Caption:='停止攻击'; //改变按钮文字
end
else begin
timer1.Enabled:=false; //停止定时器
Button2.Caption:='自动攻击'; //改变按钮文字
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
application.ProcessMessages; //防止界面死掉
Button1Click(self); //按照设定的时间间隔自动点击发送按钮
end;
end.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询