|
Apache/2.4.41 (Ubuntu) Linux vmi616275.contaboserver.net 5.4.0-84-generic #94-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) server ip : 62.171.164.128 | your ip : 127.0.0.1 safemode OFF > / home / dev2.destoffenstraat.com / vendor / ezimuel / ringphp / src / Client / |
Filename | /home/dev2.destoffenstraat.com/vendor/ezimuel/ringphp/src/Client/Middleware.php |
Size | 1.89 kb |
Permission | rw-r--r-- |
Owner | root : root |
Create time | 17-Aug-2025 10:26 |
Last modified | 07-Dec-2022 12:28 |
Last accessed | 22-Aug-2025 03:56 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
<?php
namespace GuzzleHttp\Ring\Client;
/**
* Provides basic middleware wrappers.
*
* If a middleware is more complex than a few lines of code, then it should
* be implemented in a class rather than a static method.
*/
class Middleware
{
/**
* Sends future requests to a future compatible handler while sending all
* other requests to a default handler.
*
* When the "future" option is not provided on a request, any future responses
* are automatically converted to synchronous responses and block.
*
* @param callable $default Handler used for non-streaming responses
* @param callable $future Handler used for future responses
*
* @return callable Returns the composed handler.
*/
public static function wrapFuture(
callable $default,
callable $future
) {
return function (array $request) use ($default, $future) {
return empty($request['client']['future'])
? $default($request)
: $future($request);
};
}
/**
* Sends streaming requests to a streaming compatible handler while sendin
* all other requests to a default handler.
*
* This, for example, could be useful for taking advantage of the
* performance benefits of curl while still supporting true streaming
* through the StreamHandler.
*
* @param callable $default Handler used for non-streaming responses
* @param callable $streaming Handler used for streaming responses
*
* @return callable Returns the composed handler.
*/
public static function wrapStreaming(
callable $default,
callable $streaming
) {
return function (array $request) use ($default, $streaming) {
return empty($request['client']['stream'])
? $default($request)
: $streaming($request);
};
}
}
namespace GuzzleHttp\Ring\Client;
/**
* Provides basic middleware wrappers.
*
* If a middleware is more complex than a few lines of code, then it should
* be implemented in a class rather than a static method.
*/
class Middleware
{
/**
* Sends future requests to a future compatible handler while sending all
* other requests to a default handler.
*
* When the "future" option is not provided on a request, any future responses
* are automatically converted to synchronous responses and block.
*
* @param callable $default Handler used for non-streaming responses
* @param callable $future Handler used for future responses
*
* @return callable Returns the composed handler.
*/
public static function wrapFuture(
callable $default,
callable $future
) {
return function (array $request) use ($default, $future) {
return empty($request['client']['future'])
? $default($request)
: $future($request);
};
}
/**
* Sends streaming requests to a streaming compatible handler while sendin
* all other requests to a default handler.
*
* This, for example, could be useful for taking advantage of the
* performance benefits of curl while still supporting true streaming
* through the StreamHandler.
*
* @param callable $default Handler used for non-streaming responses
* @param callable $streaming Handler used for streaming responses
*
* @return callable Returns the composed handler.
*/
public static function wrapStreaming(
callable $default,
callable $streaming
) {
return function (array $request) use ($default, $streaming) {
return empty($request['client']['stream'])
? $default($request)
: $streaming($request);
};
}
}