Completed
Push — master ( 6a3ea2...b97e84 )
by Maxence
13s
created
lib/Vendor/Http/Discovery/MessageFactoryDiscovery.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
  *
13 13
  * @deprecated This will be removed in 2.0. Consider using Psr17FactoryDiscovery.
14 14
  */
15
-final class MessageFactoryDiscovery extends ClassDiscovery
16
-{
15
+final class MessageFactoryDiscovery extends ClassDiscovery {
17 16
     /**
18 17
      * Finds a Message Factory.
19 18
      *
Please login to merge, or discard this patch.
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -13,20 +13,20 @@
 block discarded – undo
13 13
  */
14 14
 final class MessageFactoryDiscovery extends ClassDiscovery
15 15
 {
16
-    /**
17
-     * Finds a Message Factory.
18
-     *
19
-     * @return MessageFactory
20
-     *
21
-     * @throws Exception\NotFoundException
22
-     */
23
-    public static function find()
24
-    {
25
-        try {
26
-            $messageFactory = static::findOneByType(MessageFactory::class);
27
-        } catch (DiscoveryFailedException $e) {
28
-            throw new NotFoundException('No php-http message factories found. Note that the php-http message factories are deprecated in favor of the PSR-17 message factories. To use the legacy Guzzle, Diactoros or Slim Framework factories of php-http, install php-http/message and php-http/message-factory and the chosen message implementation.', 0, $e);
29
-        }
30
-        return static::instantiateClass($messageFactory);
31
-    }
16
+	/**
17
+	 * Finds a Message Factory.
18
+	 *
19
+	 * @return MessageFactory
20
+	 *
21
+	 * @throws Exception\NotFoundException
22
+	 */
23
+	public static function find()
24
+	{
25
+		try {
26
+			$messageFactory = static::findOneByType(MessageFactory::class);
27
+		} catch (DiscoveryFailedException $e) {
28
+			throw new NotFoundException('No php-http message factories found. Note that the php-http message factories are deprecated in favor of the PSR-17 message factories. To use the legacy Guzzle, Diactoros or Slim Framework factories of php-http, install php-http/message and php-http/message-factory and the chosen message implementation.', 0, $e);
29
+		}
30
+		return static::instantiateClass($messageFactory);
31
+	}
32 32
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Promise/FulfilledPromise.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
  *
8 8
  * @author Joel Wurtz <[email protected]>
9 9
  */
10
-final class FulfilledPromise implements Promise
11
-{
10
+final class FulfilledPromise implements Promise {
12 11
     /**
13 12
      * @var mixed
14 13
      */
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -9,37 +9,37 @@
 block discarded – undo
9 9
  */
10 10
 final class FulfilledPromise implements Promise
11 11
 {
12
-    /**
13
-     * @var mixed
14
-     */
15
-    private $result;
16
-    /**
17
-     * @param mixed $result
18
-     */
19
-    public function __construct($result)
20
-    {
21
-        $this->result = $result;
22
-    }
23
-    public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
24
-    {
25
-        if (null === $onFulfilled) {
26
-            return $this;
27
-        }
28
-        try {
29
-            return new self($onFulfilled($this->result));
30
-        } catch (\Exception $e) {
31
-            return new RejectedPromise($e);
32
-        }
33
-    }
34
-    public function getState()
35
-    {
36
-        return Promise::FULFILLED;
37
-    }
38
-    public function wait($unwrap = \true)
39
-    {
40
-        if ($unwrap) {
41
-            return $this->result;
42
-        }
43
-        return null;
44
-    }
12
+	/**
13
+	 * @var mixed
14
+	 */
15
+	private $result;
16
+	/**
17
+	 * @param mixed $result
18
+	 */
19
+	public function __construct($result)
20
+	{
21
+		$this->result = $result;
22
+	}
23
+	public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
24
+	{
25
+		if (null === $onFulfilled) {
26
+			return $this;
27
+		}
28
+		try {
29
+			return new self($onFulfilled($this->result));
30
+		} catch (\Exception $e) {
31
+			return new RejectedPromise($e);
32
+		}
33
+	}
34
+	public function getState()
35
+	{
36
+		return Promise::FULFILLED;
37
+	}
38
+	public function wait($unwrap = \true)
39
+	{
40
+		if ($unwrap) {
41
+			return $this->result;
42
+		}
43
+		return null;
44
+	}
45 45
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Promise/Promise.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -13,8 +13,7 @@
 block discarded – undo
13 13
  * @author Joel Wurtz <[email protected]>
14 14
  * @author Márk Sági-Kazár <[email protected]>
15 15
  */
16
-interface Promise
17
-{
16
+interface Promise {
18 17
     /**
19 18
      * Promise has not been fulfilled or rejected.
20 19
      */
Please login to merge, or discard this patch.
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
  */
16 16
 interface Promise
17 17
 {
18
-    /**
19
-     * Promise has not been fulfilled or rejected.
20
-     */
21
-    const PENDING = 'pending';
22
-    /**
23
-     * Promise has been fulfilled.
24
-     */
25
-    const FULFILLED = 'fulfilled';
26
-    /**
27
-     * Promise has been rejected.
28
-     */
29
-    const REJECTED = 'rejected';
30
-    /**
31
-     * Adds behavior for when the promise is resolved or rejected (response will be available, or error happens).
32
-     *
33
-     * If you do not care about one of the cases, you can set the corresponding callable to null
34
-     * The callback will be called when the value arrived and never more than once.
35
-     *
36
-     * @param callable|null $onFulfilled called when a response will be available
37
-     * @param callable|null $onRejected  called when an exception occurs
38
-     *
39
-     * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected)
40
-     */
41
-    public function then(?callable $onFulfilled = null, ?callable $onRejected = null);
42
-    /**
43
-     * Returns the state of the promise, one of PENDING, FULFILLED or REJECTED.
44
-     *
45
-     * @return string
46
-     */
47
-    public function getState();
48
-    /**
49
-     * Wait for the promise to be fulfilled or rejected.
50
-     *
51
-     * When this method returns, the request has been resolved and if callables have been
52
-     * specified, the appropriate one has terminated.
53
-     *
54
-     * When $unwrap is true (the default), the response is returned, or the exception thrown
55
-     * on failure. Otherwise, nothing is returned or thrown.
56
-     *
57
-     * @param bool $unwrap Whether to return resolved value / throw reason or not
58
-     *
59
-     * @return ($unwrap is true ? mixed : null) Resolved value, null if $unwrap is set to false
60
-     *
61
-     * @throws \Throwable the rejection reason if $unwrap is set to true and the request failed
62
-     */
63
-    public function wait($unwrap = \true);
18
+	/**
19
+	 * Promise has not been fulfilled or rejected.
20
+	 */
21
+	const PENDING = 'pending';
22
+	/**
23
+	 * Promise has been fulfilled.
24
+	 */
25
+	const FULFILLED = 'fulfilled';
26
+	/**
27
+	 * Promise has been rejected.
28
+	 */
29
+	const REJECTED = 'rejected';
30
+	/**
31
+	 * Adds behavior for when the promise is resolved or rejected (response will be available, or error happens).
32
+	 *
33
+	 * If you do not care about one of the cases, you can set the corresponding callable to null
34
+	 * The callback will be called when the value arrived and never more than once.
35
+	 *
36
+	 * @param callable|null $onFulfilled called when a response will be available
37
+	 * @param callable|null $onRejected  called when an exception occurs
38
+	 *
39
+	 * @return Promise a new resolved promise with value of the executed callback (onFulfilled / onRejected)
40
+	 */
41
+	public function then(?callable $onFulfilled = null, ?callable $onRejected = null);
42
+	/**
43
+	 * Returns the state of the promise, one of PENDING, FULFILLED or REJECTED.
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public function getState();
48
+	/**
49
+	 * Wait for the promise to be fulfilled or rejected.
50
+	 *
51
+	 * When this method returns, the request has been resolved and if callables have been
52
+	 * specified, the appropriate one has terminated.
53
+	 *
54
+	 * When $unwrap is true (the default), the response is returned, or the exception thrown
55
+	 * on failure. Otherwise, nothing is returned or thrown.
56
+	 *
57
+	 * @param bool $unwrap Whether to return resolved value / throw reason or not
58
+	 *
59
+	 * @return ($unwrap is true ? mixed : null) Resolved value, null if $unwrap is set to false
60
+	 *
61
+	 * @throws \Throwable the rejection reason if $unwrap is set to true and the request failed
62
+	 */
63
+	public function wait($unwrap = \true);
64 64
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Promise/RejectedPromise.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,8 +7,7 @@
 block discarded – undo
7 7
  *
8 8
  * @author Joel Wurtz <[email protected]>
9 9
  */
10
-final class RejectedPromise implements Promise
11
-{
10
+final class RejectedPromise implements Promise {
12 11
     /**
13 12
      * @var \Throwable
14 13
      */
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -9,34 +9,34 @@
 block discarded – undo
9 9
  */
10 10
 final class RejectedPromise implements Promise
11 11
 {
12
-    /**
13
-     * @var \Throwable
14
-     */
15
-    private $exception;
16
-    public function __construct(\Throwable $exception)
17
-    {
18
-        $this->exception = $exception;
19
-    }
20
-    public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
21
-    {
22
-        if (null === $onRejected) {
23
-            return $this;
24
-        }
25
-        try {
26
-            return new FulfilledPromise($onRejected($this->exception));
27
-        } catch (\Exception $e) {
28
-            return new self($e);
29
-        }
30
-    }
31
-    public function getState()
32
-    {
33
-        return Promise::REJECTED;
34
-    }
35
-    public function wait($unwrap = \true)
36
-    {
37
-        if ($unwrap) {
38
-            throw $this->exception;
39
-        }
40
-        return null;
41
-    }
12
+	/**
13
+	 * @var \Throwable
14
+	 */
15
+	private $exception;
16
+	public function __construct(\Throwable $exception)
17
+	{
18
+		$this->exception = $exception;
19
+	}
20
+	public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
21
+	{
22
+		if (null === $onRejected) {
23
+			return $this;
24
+		}
25
+		try {
26
+			return new FulfilledPromise($onRejected($this->exception));
27
+		} catch (\Exception $e) {
28
+			return new self($e);
29
+		}
30
+	}
31
+	public function getState()
32
+	{
33
+		return Promise::REJECTED;
34
+	}
35
+	public function wait($unwrap = \true)
36
+	{
37
+		if ($unwrap) {
38
+			throw $this->exception;
39
+		}
40
+		return null;
41
+	}
42 42
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Client/Exception.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -9,6 +9,5 @@
 block discarded – undo
9 9
  *
10 10
  * @author Márk Sági-Kazár <[email protected]>
11 11
  */
12
-interface Exception extends PsrClientException
13
-{
12
+interface Exception extends PsrClientException {
14 13
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Client/HttpAsyncClient.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,8 +10,7 @@
 block discarded – undo
10 10
  *
11 11
  * @author Joel Wurtz <[email protected]>
12 12
  */
13
-interface HttpAsyncClient
14
-{
13
+interface HttpAsyncClient {
15 14
     /**
16 15
      * Sends a PSR-7 request in an asynchronous way.
17 16
      *
Please login to merge, or discard this patch.
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
  */
12 12
 interface HttpAsyncClient
13 13
 {
14
-    /**
15
-     * Sends a PSR-7 request in an asynchronous way.
16
-     *
17
-     * Exceptions related to processing the request are available from the returned Promise.
18
-     *
19
-     * @return Promise resolves a PSR-7 Response or fails with an Http\Client\Exception
20
-     *
21
-     * @throws \Exception If processing the request is impossible (eg. bad configuration).
22
-     */
23
-    public function sendAsyncRequest(RequestInterface $request);
14
+	/**
15
+	 * Sends a PSR-7 request in an asynchronous way.
16
+	 *
17
+	 * Exceptions related to processing the request are available from the returned Promise.
18
+	 *
19
+	 * @return Promise resolves a PSR-7 Response or fails with an Http\Client\Exception
20
+	 *
21
+	 * @throws \Exception If processing the request is impossible (eg. bad configuration).
22
+	 */
23
+	public function sendAsyncRequest(RequestInterface $request);
24 24
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Client/Exception/HttpException.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,8 +12,7 @@
 block discarded – undo
12 12
  *
13 13
  * @author Márk Sági-Kazár <[email protected]>
14 14
  */
15
-class HttpException extends RequestException
16
-{
15
+class HttpException extends RequestException {
17 16
     /**
18 17
      * @var ResponseInterface
19 18
      */
Please login to merge, or discard this patch.
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -13,34 +13,34 @@
 block discarded – undo
13 13
  */
14 14
 class HttpException extends RequestException
15 15
 {
16
-    /**
17
-     * @var ResponseInterface
18
-     */
19
-    protected $response;
20
-    /**
21
-     * @param string $message
22
-     */
23
-    public function __construct($message, RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null)
24
-    {
25
-        parent::__construct($message, $request, $previous);
26
-        $this->response = $response;
27
-        $this->code = $response->getStatusCode();
28
-    }
29
-    /**
30
-     * Returns the response.
31
-     *
32
-     * @return ResponseInterface
33
-     */
34
-    public function getResponse()
35
-    {
36
-        return $this->response;
37
-    }
38
-    /**
39
-     * Factory method to create a new exception with a normalized error message.
40
-     */
41
-    public static function create(RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null)
42
-    {
43
-        $message = \sprintf('[url] %s [http method] %s [status code] %s [reason phrase] %s', $request->getRequestTarget(), $request->getMethod(), $response->getStatusCode(), $response->getReasonPhrase());
44
-        return new static($message, $request, $response, $previous);
45
-    }
16
+	/**
17
+	 * @var ResponseInterface
18
+	 */
19
+	protected $response;
20
+	/**
21
+	 * @param string $message
22
+	 */
23
+	public function __construct($message, RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null)
24
+	{
25
+		parent::__construct($message, $request, $previous);
26
+		$this->response = $response;
27
+		$this->code = $response->getStatusCode();
28
+	}
29
+	/**
30
+	 * Returns the response.
31
+	 *
32
+	 * @return ResponseInterface
33
+	 */
34
+	public function getResponse()
35
+	{
36
+		return $this->response;
37
+	}
38
+	/**
39
+	 * Factory method to create a new exception with a normalized error message.
40
+	 */
41
+	public static function create(RequestInterface $request, ResponseInterface $response, ?\Exception $previous = null)
42
+	{
43
+		$message = \sprintf('[url] %s [http method] %s [status code] %s [reason phrase] %s', $request->getRequestTarget(), $request->getMethod(), $response->getStatusCode(), $response->getReasonPhrase());
44
+		return new static($message, $request, $response, $previous);
45
+	}
46 46
 }
Please login to merge, or discard this patch.
lib/Vendor/Http/Client/Promise/HttpRejectedPromise.php 2 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -5,8 +5,7 @@
 block discarded – undo
5 5
 use OCA\FullTextSearch_Elasticsearch\Vendor\Http\Client\Exception;
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Http\Promise\Promise;
7 7
 
8
-final class HttpRejectedPromise implements Promise
9
-{
8
+final class HttpRejectedPromise implements Promise {
10 9
     /**
11 10
      * @var Exception
12 11
      */
Please login to merge, or discard this patch.
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -6,37 +6,37 @@
 block discarded – undo
6 6
 use OCA\FullTextSearch_Elasticsearch\Vendor\Http\Promise\Promise;
7 7
 final class HttpRejectedPromise implements Promise
8 8
 {
9
-    /**
10
-     * @var Exception
11
-     */
12
-    private $exception;
13
-    public function __construct(Exception $exception)
14
-    {
15
-        $this->exception = $exception;
16
-    }
17
-    public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
18
-    {
19
-        if (null === $onRejected) {
20
-            return $this;
21
-        }
22
-        try {
23
-            $result = $onRejected($this->exception);
24
-            if ($result instanceof Promise) {
25
-                return $result;
26
-            }
27
-            return new HttpFulfilledPromise($result);
28
-        } catch (Exception $e) {
29
-            return new self($e);
30
-        }
31
-    }
32
-    public function getState()
33
-    {
34
-        return Promise::REJECTED;
35
-    }
36
-    public function wait($unwrap = \true)
37
-    {
38
-        if ($unwrap) {
39
-            throw $this->exception;
40
-        }
41
-    }
9
+	/**
10
+	 * @var Exception
11
+	 */
12
+	private $exception;
13
+	public function __construct(Exception $exception)
14
+	{
15
+		$this->exception = $exception;
16
+	}
17
+	public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
18
+	{
19
+		if (null === $onRejected) {
20
+			return $this;
21
+		}
22
+		try {
23
+			$result = $onRejected($this->exception);
24
+			if ($result instanceof Promise) {
25
+				return $result;
26
+			}
27
+			return new HttpFulfilledPromise($result);
28
+		} catch (Exception $e) {
29
+			return new self($e);
30
+		}
31
+	}
32
+	public function getState()
33
+	{
34
+		return Promise::REJECTED;
35
+	}
36
+	public function wait($unwrap = \true)
37
+	{
38
+		if ($unwrap) {
39
+			throw $this->exception;
40
+		}
41
+	}
42 42
 }
Please login to merge, or discard this patch.
lib/Vendor/GuzzleHttp/PrepareBodyMiddleware.php 3 patches
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,8 +11,7 @@
 block discarded – undo
11 11
  *
12 12
  * @final
13 13
  */
14
-class PrepareBodyMiddleware
15
-{
14
+class PrepareBodyMiddleware {
16 15
     /**
17 16
      * @var callable(RequestInterface, array): PromiseInterface
18 17
      */
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@
 block discarded – undo
79 79
         // determined, or the size is greater than the cutoff threshold
80 80
         $body = $request->getBody();
81 81
         $size = $body->getSize();
82
-        if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
82
+        if ($size === null || $size >= (int)$expect || !$body->isSeekable()) {
83 83
             $modify['set_headers']['Expect'] = '100-Continue';
84 84
         }
85 85
     }
Please login to merge, or discard this patch.
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -12,75 +12,75 @@
 block discarded – undo
12 12
  */
13 13
 class PrepareBodyMiddleware
14 14
 {
15
-    /**
16
-     * @var callable(RequestInterface, array): PromiseInterface
17
-     */
18
-    private $nextHandler;
19
-    /**
20
-     * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke.
21
-     */
22
-    public function __construct(callable $nextHandler)
23
-    {
24
-        $this->nextHandler = $nextHandler;
25
-    }
26
-    public function __invoke(RequestInterface $request, array $options) : PromiseInterface
27
-    {
28
-        $fn = $this->nextHandler;
29
-        // Don't do anything if the request has no body.
30
-        if ($request->getBody()->getSize() === 0) {
31
-            return $fn($request, $options);
32
-        }
33
-        $modify = [];
34
-        // Add a default content-type if possible.
35
-        if (!$request->hasHeader('Content-Type')) {
36
-            if ($uri = $request->getBody()->getMetadata('uri')) {
37
-                if (\is_string($uri) && ($type = Psr7\MimeType::fromFilename($uri))) {
38
-                    $modify['set_headers']['Content-Type'] = $type;
39
-                }
40
-            }
41
-        }
42
-        // Add a default content-length or transfer-encoding header.
43
-        if (!$request->hasHeader('Content-Length') && !$request->hasHeader('Transfer-Encoding')) {
44
-            $size = $request->getBody()->getSize();
45
-            if ($size !== null) {
46
-                $modify['set_headers']['Content-Length'] = $size;
47
-            } else {
48
-                $modify['set_headers']['Transfer-Encoding'] = 'chunked';
49
-            }
50
-        }
51
-        // Add the expect header if needed.
52
-        $this->addExpectHeader($request, $options, $modify);
53
-        return $fn(Psr7\Utils::modifyRequest($request, $modify), $options);
54
-    }
55
-    /**
56
-     * Add expect header
57
-     */
58
-    private function addExpectHeader(RequestInterface $request, array $options, array &$modify) : void
59
-    {
60
-        // Determine if the Expect header should be used
61
-        if ($request->hasHeader('Expect')) {
62
-            return;
63
-        }
64
-        $expect = $options['expect'] ?? null;
65
-        // Return if disabled or using HTTP/1.0
66
-        if ($expect === \false || $request->getProtocolVersion() === '1.0') {
67
-            return;
68
-        }
69
-        // The expect header is unconditionally enabled
70
-        if ($expect === \true) {
71
-            $modify['set_headers']['Expect'] = '100-Continue';
72
-            return;
73
-        }
74
-        // By default, send the expect header when the payload is > 1mb
75
-        if ($expect === null) {
76
-            $expect = 1048576;
77
-        }
78
-        // Always add if the body cannot be rewound, the size cannot be
79
-        // determined, or the size is greater than the cutoff threshold
80
-        $body = $request->getBody();
81
-        $size = $body->getSize();
82
-        if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
83
-            $modify['set_headers']['Expect'] = '100-Continue';
84
-        }
85
-    }
15
+	/**
16
+	 * @var callable(RequestInterface, array): PromiseInterface
17
+	 */
18
+	private $nextHandler;
19
+	/**
20
+	 * @param callable(RequestInterface, array): PromiseInterface $nextHandler Next handler to invoke.
21
+	 */
22
+	public function __construct(callable $nextHandler)
23
+	{
24
+		$this->nextHandler = $nextHandler;
25
+	}
26
+	public function __invoke(RequestInterface $request, array $options) : PromiseInterface
27
+	{
28
+		$fn = $this->nextHandler;
29
+		// Don't do anything if the request has no body.
30
+		if ($request->getBody()->getSize() === 0) {
31
+			return $fn($request, $options);
32
+		}
33
+		$modify = [];
34
+		// Add a default content-type if possible.
35
+		if (!$request->hasHeader('Content-Type')) {
36
+			if ($uri = $request->getBody()->getMetadata('uri')) {
37
+				if (\is_string($uri) && ($type = Psr7\MimeType::fromFilename($uri))) {
38
+					$modify['set_headers']['Content-Type'] = $type;
39
+				}
40
+			}
41
+		}
42
+		// Add a default content-length or transfer-encoding header.
43
+		if (!$request->hasHeader('Content-Length') && !$request->hasHeader('Transfer-Encoding')) {
44
+			$size = $request->getBody()->getSize();
45
+			if ($size !== null) {
46
+				$modify['set_headers']['Content-Length'] = $size;
47
+			} else {
48
+				$modify['set_headers']['Transfer-Encoding'] = 'chunked';
49
+			}
50
+		}
51
+		// Add the expect header if needed.
52
+		$this->addExpectHeader($request, $options, $modify);
53
+		return $fn(Psr7\Utils::modifyRequest($request, $modify), $options);
54
+	}
55
+	/**
56
+	 * Add expect header
57
+	 */
58
+	private function addExpectHeader(RequestInterface $request, array $options, array &$modify) : void
59
+	{
60
+		// Determine if the Expect header should be used
61
+		if ($request->hasHeader('Expect')) {
62
+			return;
63
+		}
64
+		$expect = $options['expect'] ?? null;
65
+		// Return if disabled or using HTTP/1.0
66
+		if ($expect === \false || $request->getProtocolVersion() === '1.0') {
67
+			return;
68
+		}
69
+		// The expect header is unconditionally enabled
70
+		if ($expect === \true) {
71
+			$modify['set_headers']['Expect'] = '100-Continue';
72
+			return;
73
+		}
74
+		// By default, send the expect header when the payload is > 1mb
75
+		if ($expect === null) {
76
+			$expect = 1048576;
77
+		}
78
+		// Always add if the body cannot be rewound, the size cannot be
79
+		// determined, or the size is greater than the cutoff threshold
80
+		$body = $request->getBody();
81
+		$size = $body->getSize();
82
+		if ($size === null || $size >= (int) $expect || !$body->isSeekable()) {
83
+			$modify['set_headers']['Expect'] = '100-Continue';
84
+		}
85
+	}
86 86
 }
Please login to merge, or discard this patch.