summaryrefslogtreecommitdiff
path: root/packages/fcl-web
diff options
context:
space:
mode:
authormichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-16 22:15:37 +0000
committermichael <michael@3ad0048d-3df7-0310-abae-a5850022a9f2>2021-03-16 22:15:37 +0000
commit0859996bb6e99d9936176cf612c4047b58eb852c (patch)
tree02bb51bd1f6d34703e05b7448d2fcb44a84b3aec /packages/fcl-web
parent319e48ba82e18600ee00ccebd3952bb1c8f86d16 (diff)
downloadfpc-0859996bb6e99d9936176cf612c4047b58eb852c.tar.gz
* Patch method contribution
git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@48992 3ad0048d-3df7-0310-abae-a5850022a9f2
Diffstat (limited to 'packages/fcl-web')
-rw-r--r--packages/fcl-web/src/base/fphttpclient.pp108
1 files changed, 108 insertions, 0 deletions
diff --git a/packages/fcl-web/src/base/fphttpclient.pp b/packages/fcl-web/src/base/fphttpclient.pp
index fdecc9e0af..9449c0ddea 100644
--- a/packages/fcl-web/src/base/fphttpclient.pp
+++ b/packages/fcl-web/src/base/fphttpclient.pp
@@ -231,6 +231,17 @@ Type
Class Procedure SimpleDelete(const URL: string; Response : TStrings);
Class Procedure SimpleDelete(const URL: string; const LocalFileName: String);
Class function SimpleDelete(const URL: string) : RawByteString;
+ // Simple Patch
+ // Put URL, and Requestbody. Return response in Stream, File, TstringList or String;
+ Procedure Patch(const URL: string; const Response: TStream);
+ Procedure Patch(const URL: string; Response : TStrings);
+ Procedure Patch(const URL: string; const LocalFileName: String);
+ function Patch(const URL: string) : RawByteString;
+ // Simple class methods.
+ Class Procedure SimplePatch(const URL: string; const Response: TStream);
+ Class Procedure SimplePatch(const URL: string; Response : TStrings);
+ Class Procedure SimplePatch(const URL: string; const LocalFileName: String);
+ Class function SimplePatch(const URL: string) : RawByteString;
// Simple Options
// Options from URL, and Requestbody. Return response in Stream, File, TstringList or String;
Procedure Options(const URL: string; const Response: TStream);
@@ -1846,6 +1857,103 @@ begin
end;
end;
+
+
+
+
+procedure TFPCustomHTTPClient.Patch(const URL: string; const Response: TStream);
+begin
+ HTTPMethod('PATCH',URL,Response,[]);
+end;
+
+procedure TFPCustomHTTPClient.Patch(const URL: string; Response: TStrings);
+begin
+ Response.Text:=Patch(URL);
+end;
+
+procedure TFPCustomHTTPClient.Patch(const URL: string; const LocalFileName: String
+ );
+
+Var
+ F : TFileStream;
+
+begin
+ F:=TFileStream.Create(LocalFileName,fmCreate);
+ try
+ Patch(URL,F);
+ finally
+ F.Free;
+ end;
+end;
+
+function TFPCustomHTTPClient.Patch(const URL: string): RawByteString;
+Var
+ SS : TRawByteStringStream;
+begin
+ SS:=TRawByteStringStream.Create();
+ try
+ Patch(URL,SS);
+ Result:=SS.Datastring;
+ finally
+ SS.Free;
+ end;
+end;
+
+class procedure TFPCustomHTTPClient.SimplePatch(const URL: string;
+ const Response: TStream);
+
+begin
+ With Self.Create(nil) do
+ try
+ KeepConnection := False;
+ Patch(URL,Response);
+ finally
+ Free;
+ end;
+end;
+
+class procedure TFPCustomHTTPClient.SimplePatch(const URL: string;
+ Response: TStrings);
+
+begin
+ With Self.Create(nil) do
+ try
+ KeepConnection := False;
+ Patch(URL,Response);
+ finally
+ Free;
+ end;
+end;
+
+class procedure TFPCustomHTTPClient.SimplePatch(const URL: string;
+ const LocalFileName: String);
+
+begin
+ With Self.Create(nil) do
+ try
+ KeepConnection := False;
+ Patch(URL,LocalFileName);
+ finally
+ Free;
+ end;
+end;
+
+class function TFPCustomHTTPClient.SimplePatch(const URL: string): RawByteString;
+
+begin
+ With Self.Create(nil) do
+ try
+ KeepConnection := False;
+ Result:=Patch(URL);
+ finally
+ Free;
+ end;
+end;
+
+
+
+
+
procedure TFPCustomHTTPClient.Options(const URL: string; const Response: TStream
);
begin