德尔福 2009
我最近从多个 GET 请求切换到单个 POST,我认为这会更有效,但结果却慢得多。它从 1-2 秒变为 8-10 秒,我不知道为什么。
例子
unit Unit4;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdHTTP;
type
TForm4 = class(TForm)
d: TIdHTTP;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form4: TForm4;
implementation
{$R *.dfm}
procedure TForm4.Button1Click(Sender: TObject);
var m: tmemorystream;
data: tstringlist;
i: integer;
begin
memo1.Clear;
m:=tmemorystream.Create;
data:=tstringlist.Create;
data.Add(format('test1');
data.Add(format('test2');
d.Post('http://www.someurl.com/test.php', data, m);
m.Position:=0;
data.LoadFromStream(m);
memo1.Lines.Add('Received:');
for i := 0 to data.count - 1 do
memo1.Lines.Add(data[i]);
m.Free;
data.Free;
end;
end.
并在服务器上
<?php
echo "1\n";
?>