]> git.mxchange.org Git - friendica.git/commitdiff
[WIP] WebDav Storage backend
authorPhilipp <admin@philipp.info>
Wed, 25 Aug 2021 21:47:18 +0000 (23:47 +0200)
committerPhilipp <admin@philipp.info>
Wed, 25 Aug 2021 21:47:18 +0000 (23:47 +0200)
src/Network/HTTPClient.php
src/Network/HTTPClientOptions.php
src/Network/IHTTPClient.php

index d265411c2cd12122f6b719f1add27a32edda3b04..053c65c0d1a7f789bc54936f15778a0aced896cc 100644 (file)
@@ -125,6 +125,10 @@ class HTTPClient implements IHTTPClient
                        $conf[RequestOptions::BODY] = $opts[HTTPClientOptions::BODY];
                }
 
+               if (!empty($opts[HTTPClientOptions::AUTH])) {
+                       $conf[RequestOptions::AUTH] = $opts[HTTPClientOptions::AUTH];
+               }
+
                $conf[RequestOptions::ON_HEADERS] = function (ResponseInterface $response) use ($opts) {
                        if (!empty($opts[HTTPClientOptions::CONTENT_LENGTH]) &&
                                (int)$response->getHeaderLine('Content-Length') > $opts[HTTPClientOptions::CONTENT_LENGTH]) {
@@ -135,17 +139,7 @@ class HTTPClient implements IHTTPClient
                try {
                        $this->logger->debug('http request config.', ['url' => $url, 'method' => $method, 'options' => $conf]);
 
-                       switch ($method) {
-                               case 'get':
-                               case 'head':
-                               case 'post':
-                               case 'put':
-                               case 'delete':
-                                       $response = $this->client->$method($url, $conf);
-                                       break;
-                               default:
-                                       throw new TransferException('Invalid method');
-                       }
+                       $response = $this->client->request($method, $url, $conf);
                        return new GuzzleResponse($response, $url);
                } catch (TransferException $exception) {
                        if ($exception instanceof RequestException &&
index f199360362385b35b0f0509f70e017968eb4d7e4..f9438fb47965605bfac55e4d3165697ca2a6ad60 100644 (file)
@@ -37,4 +37,8 @@ class HTTPClientOptions
         * body: (mixed) Setting the body for sending data
         */
        const BODY = RequestOptions::BODY;
+       /**
+        * auth: (array) Authentication settings for specific requests
+        */
+       const AUTH = RequestOptions::AUTH;
 }
index 2f8bab46fca03523a7f93548c572b692f4416bb2..87168055321f4bc6291b1f3d92021286a8461fc1 100644 (file)
@@ -97,6 +97,7 @@ interface IHTTPClient
         *                           'cookiejar' => path to cookie jar file
         *                           'header' => header array
         *                           'content_length' => int maximum File content length
+        *                           'auth' => array authentication settings
         *
         * @return IHTTPResult
         */