From 3044e466b9361eb2c0bbf27f3cb100fd0e181a57 Mon Sep 17 00:00:00 2001 From: beu Date: Sat, 3 Aug 2024 11:56:21 +0200 Subject: [PATCH] Add PUT method --- core/Files/AsyncHttpRequest.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/core/Files/AsyncHttpRequest.php b/core/Files/AsyncHttpRequest.php index fc9c9a34..0bd5a4df 100644 --- a/core/Files/AsyncHttpRequest.php +++ b/core/Files/AsyncHttpRequest.php @@ -136,6 +136,31 @@ class AsyncHttpRequest implements UsageInformationAble { $this->processRequest($request); } + /** + * Carry out a PutData Request + */ + public function putData() { + array_push($this->headers, 'Content-Type: ' . $this->contentType); + array_push($this->headers, 'Keep-Alive: timeout=600, max=2000'); + array_push($this->headers, 'Connection: Keep-Alive'); + array_push($this->headers, 'Expect:'); + array_push($this->headers, 'Accept-Charset: utf-8'); + + $content = $this->content; + if ($this->compression) { + $content = gzencode($this->content); + array_push($this->headers, 'Content-Encoding: gzip'); + } + + + $request = $this->newRequest($this->url, $this->timeout); + $request->getOptions()->set(CURLOPT_CUSTOMREQUEST, 'PUT')// patch method + ->set(CURLOPT_POSTFIELDS, $content)// put content field + ->set(CURLOPT_HTTPHEADER, $this->headers) // headers + ; + + $this->processRequest($request); + } /** * Processes the Request