-
Notifications
You must be signed in to change notification settings - Fork 3
/
formliqpool.pas
59 lines (44 loc) · 1.14 KB
/
formliqpool.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
unit formliqpool;
{$mode ObjFPC}{$H+}
interface
uses
Classes, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls,
fphttpclient;
type
{ TForm7 }
TForm7 = class(TForm)
Memo1: TMemo;
PageControl1: TPageControl;
TabConsole: TTabSheet;
TabTrade: TTabSheet;
private
public
end;
Function PostMessageToHost(host:string;port:integer;message:string):string;
var
Form7: TForm7;
IMPLEMENTATION
Function PostMessageToHost(host:string;port:integer;message:string):string;
var
HTTPClient: TFPHTTPClient;
Resultado : String = '';
RequestBodyStream: TStringStream;
{ No need for the params string list }
begin
Result := '';
HTTPClient := TFPHTTPClient.Create(nil);
RequestBodyStream:= TStringStream.Create(message, TEncoding.UTF8);
HTTPClient.IOTimeout:=3000; //
TRY
HTTPClient.AllowRedirect := True; // <-- I always forget this LOL!!
HTTPClient.RequestBody:= RequestBodyStream;
Resultado := HTTPClient.Post('http://'+host+':'+Port.ToString);
Except on E:Exception do
Resultado := 'ERROR : '+E.Message;
end;
Result := Resultado;
RequestBodyStream.Free;
HTTPClient.Free;
End;
{$R *.lfm}
END.