WordPress

Briefly unavailable for scheduled maintenance.
Check back in a some hours.
403WebShell
403Webshell
Server IP : 38.242.244.58  /  Your IP : 216.73.216.32
Web Server : Apache/2.4.41 (Ubuntu)
System : Linux vmi1486879.contaboserver.net 5.4.0-166-generic #183-Ubuntu SMP Mon Oct 2 11:28:33 UTC 2023 x86_64
User : root ( 0)
PHP Version : 7.4.3-4ubuntu2.19
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/html/sura/vendor/php-http/httplug-bundle/src/Collector/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/html/sura/vendor/php-http/httplug-bundle/src/Collector/ProfilePlugin.php
<?php

declare(strict_types=1);

namespace Http\HttplugBundle\Collector;

use Exception;
use Http\Client\Common\Plugin;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
 * The ProfilePlugin decorates any Plugin to fill Profile to keep representation of plugin input/output. Created profile
 * is pushed in the current Stack.
 *
 * @author Fabien Bourigault <bourigaultfabien@gmail.com>
 *
 * @internal
 */
class ProfilePlugin implements Plugin
{
    use Plugin\VersionBridgePlugin;

    /**
     * @var Plugin
     */
    private $plugin;

    /**
     * @var Collector
     */
    private $collector;

    /**
     * @var Formatter
     */
    private $formatter;

    public function __construct(Plugin $plugin, Collector $collector, Formatter $formatter)
    {
        $this->plugin = $plugin;
        $this->collector = $collector;
        $this->formatter = $formatter;
    }

    protected function doHandleRequest(RequestInterface $request, callable $next, callable $first)
    {
        $profile = new Profile(get_class($this->plugin));

        $stack = $this->collector->getActiveStack();
        $stack->addProfile($profile);

        // wrap the next callback to profile the plugin request changes
        $wrappedNext = function (RequestInterface $request) use ($next, $profile) {
            $this->onOutgoingRequest($request, $profile);

            return $next($request);
        };

        // wrap the first callback to profile the plugin request changes
        $wrappedFirst = function (RequestInterface $request) use ($first, $profile) {
            $this->onOutgoingRequest($request, $profile);

            return $first($request);
        };

        try {
            $promise = $this->plugin->handleRequest($request, $wrappedNext, $wrappedFirst);
        } catch (Exception $e) {
            $this->onException($request, $profile, $e, $stack);

            throw $e;
        }

        return $promise->then(function (ResponseInterface $response) use ($profile, $request, $stack) {
            $this->onOutgoingResponse($response, $profile, $request, $stack);

            return $response;
        }, function (Exception $exception) use ($profile, $request, $stack) {
            $this->onException($request, $profile, $exception, $stack);

            throw $exception;
        });
    }

    /**
     * @param Stack $stack
     */
    private function onException(
        RequestInterface $request,
        Profile $profile,
        Exception $exception,
        Stack $stack = null
    ) {
        $profile->setFailed(true);
        $profile->setResponse($this->formatter->formatException($exception));
        $this->collectRequestInformation($request, $stack);
    }

    private function onOutgoingRequest(RequestInterface $request, Profile $profile)
    {
        $profile->setRequest($this->formatter->formatRequest($request));
    }

    /**
     * @param Stack $stack
     */
    private function onOutgoingResponse(ResponseInterface $response, Profile $profile, RequestInterface $request, Stack $stack = null)
    {
        $profile->setResponse($this->formatter->formatResponse($response));
        $this->collectRequestInformation($request, $stack);
    }

    /**
     * Collect request information when not already done by the HTTP client. This happens when using the CachePlugin
     * and the cache is hit without re-validation.
     */
    private function collectRequestInformation(RequestInterface $request, Stack $stack = null)
    {
        $uri = $request->getUri();
        if (empty($stack->getRequestTarget())) {
            $stack->setRequestTarget($request->getRequestTarget());
        }
        if (empty($stack->getRequestMethod())) {
            $stack->setRequestMethod($request->getMethod());
        }
        if (empty($stack->getRequestScheme())) {
            $stack->setRequestScheme($uri->getScheme());
        }
        if (empty($stack->getRequestPort())) {
            $stack->setRequestPort($uri->getPort());
        }
        if (empty($stack->getRequestHost())) {
            $stack->setRequestHost($uri->getHost());
        }
        if (empty($stack->getClientRequest())) {
            $stack->setClientRequest($this->formatter->formatRequest($request));
        }
        if (empty($stack->getCurlCommand())) {
            $stack->setCurlCommand($this->formatter->formatAsCurlCommand($request));
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit