delphimvcframework/samples/sslclient/MainFormU.pas

91 lines
1.7 KiB
ObjectPascal
Raw Normal View History

2014-04-02 09:03:13 +02:00
unit MainFormU;
interface
uses
Winapi.Windows,
Winapi.Messages,
System.SysUtils,
System.Variants,
System.Classes,
Vcl.Graphics,
Vcl.Controls,
Vcl.Forms,
Vcl.Dialogs,
IPPeerClient,
Vcl.StdCtrls,
MVCFramework.RESTClient,
2020-08-26 22:13:18 +02:00
MVCFramework.RESTClient.Intf,
REST.Client,
2014-04-02 09:03:13 +02:00
Data.Bind.Components,
Data.Bind.ObjectScope,
IdIOHandler,
IdIOHandlerSocket,
IdIOHandlerStack,
IdSSL,
IdSSLOpenSSL,
IdBaseComponent,
IdComponent,
IdTCPConnection,
IdTCPClient,
2020-08-26 22:13:18 +02:00
IdHTTP,
REST.Types;
2014-04-02 09:03:13 +02:00
type
TForm9 = class(TForm)
RESTClient1: TRESTClient;
RESTRequest1: TRESTRequest;
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
IdSSLIOHandlerSocketOpenSSL1: TIdSSLIOHandlerSocketOpenSSL;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
2020-08-26 22:13:18 +02:00
Clt: IMVCRESTClient;
2014-04-02 09:03:13 +02:00
{ Private declarations }
public
{ Public declarations }
end;
var
Form9: TForm9;
implementation
{$R *.dfm}
procedure TForm9.Button1Click(Sender: TObject);
begin
RESTRequest1.ExecuteAsync(
procedure
begin
Memo1.Lines.Text := RESTRequest1.Response.JSONValue.ToString;
end);
end;
procedure TForm9.Button2Click(Sender: TObject);
begin
2020-08-26 22:13:18 +02:00
Clt.Async(
procedure(Resp: IMVCRESTResponse)
2014-04-02 09:03:13 +02:00
begin
2020-08-26 22:13:18 +02:00
Memo1.Lines.Text := Resp.Content;
Memo1.Lines.Add('Request Terminated');
end,
procedure(E: Exception)
begin
ShowMessage(E.Message);
end,
2020-08-26 22:13:18 +02:00
True
)
.Get('/people');
2014-04-02 09:03:13 +02:00
end;
procedure TForm9.FormCreate(Sender: TObject);
begin
2020-08-26 22:13:18 +02:00
Clt := TMVCRESTClient.New.BaseURL('https://localhost', 443);
2014-04-02 09:03:13 +02:00
end;
end.