unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, IdBaseComponent, IdComponent,
IdTCPConnection, IdTCPClient, IdHTTP, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
IdHTTP1: TIdHTTP;
Memo1: TMemo;
Memo2: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
RequestStream, ResponseStream: TStringStream; // 返回信息
begin
ResponseStream := TStringStream.Create('');
RequestStream := TStringStream.Create(Memo1.Lines.Text);
try
IdHTTP1.Post(Edit1.Text, RequestStream, ResponseStream);
Memo2.Text := ResponseStream.DataString;
finally
RequestStream.Free;
ResponseStream.Free;
end;
end;
end.
object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 597
ClientWidth = 759
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Edit1: TEdit
Left = 24
Top = 16
Width = 569
Height = 21
TabOrder = 0
Text = 'http://127.0.0.1:1234'
end
object Button1: TButton
Left = 608
Top = 16
Width = 75
Height = 25
Caption = 'Post'
TabOrder = 1
OnClick = Button1Click
end
object Memo1: TMemo
Left = 24
Top = 56
Width = 337
Height = 513
TabOrder = 2
end
object Memo2: TMemo
Left = 399
Top = 56
Width = 337
Height = 513
Color = clInfoBk
TabOrder = 3
end
object IdHTTP1: TIdHTTP
AllowCookies = True
ProxyParams.BasicAuthentication = False
ProxyParams.ProxyPort = 0
Request.ContentLength = -1
Request.ContentRangeEnd = -1
Request.ContentRangeStart = -1
Request.ContentRangeInstanceLength = -1
Request.Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
Request.BasicAuthentication = False
Request.UserAgent = 'Mozilla/3.0 (compatible; Indy Library)'
Request.Ranges.Units = 'bytes'
Request.Ranges = <>
HTTPOptions = [hoForceEncodeParams]
Left = 648
Top = 96
end
end