%PDF- %GIF98; %PNG; .
Cyber Programmer
Logo of a company Server : Apache
System : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64
User : ndkhermy ( 1200)
PHP Version : 8.5.12
Disable Function : NONE
Directory :  /home1/ndkhermy/public_html/website_6ca89795/vendor/egeloen/http-adapter/src/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home1/ndkhermy/public_html/website_6ca89795/vendor/egeloen/http-adapter/src/CakeHttpAdapter.php
<?php

/*
 * This file is part of the Ivory Http Adapter package.
 *
 * (c) Eric GELOEN <geloen.eric@gmail.com>
 *
 * For the full copyright and license information, please read the LICENSE
 * file that was distributed with this source code.
 */

namespace Ivory\HttpAdapter;

use Ivory\HttpAdapter\Extractor\ProtocolVersionExtractor;
use Ivory\HttpAdapter\Message\InternalRequestInterface;
use Ivory\HttpAdapter\Normalizer\BodyNormalizer;

/**
 * Cake http adapter.
 *
 * @author GeLo <geloen.eric@gmail.com>
 */
class CakeHttpAdapter extends AbstractHttpAdapter
{
    /** @var \HttpSocket */
    private $httpSocket;

    /**
     * Creates a Cake http adapter.
     *
     * @param \HttpSocket|null                               $httpSocket    The Cake http socket.
     * @param \Ivory\HttpAdapter\ConfigurationInterface|null $configuration The configuration.
     */
    public function __construct(\HttpSocket $httpSocket = null, ConfigurationInterface $configuration = null)
    {
        parent::__construct($configuration);

        $this->httpSocket = $httpSocket ?: new \HttpSocket();
    }

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return 'cake';
    }

    /**
     * {@inheritdoc}
     */
    protected function sendInternalRequest(InternalRequestInterface $internalRequest)
    {
        $this->httpSocket->config['timeout'] = $this->getConfiguration()->getTimeout();

        $request = array(
            'version'  => $this->getConfiguration()->getProtocolVersion(),
            'redirect' => false,
            'uri'      => $uri = (string) $internalRequest->getUri(),
            'method'   => $internalRequest->getMethod(),
            'header'   => $this->prepareHeaders($internalRequest),
            'body'     => $this->prepareBody($internalRequest),
        );

        try {
            $response = $this->httpSocket->request($request);
        } catch (\Exception $e) {
            throw HttpAdapterException::cannotFetchUri($uri, $this->getName(), $e->getMessage());
        }

        if (($error = $this->httpSocket->lastError()) !== null) {
            throw HttpAdapterException::cannotFetchUri($uri, $this->getName(), $error);
        }

        return $this->getConfiguration()->getMessageFactory()->createResponse(
            (integer) $response->code,
            ProtocolVersionExtractor::extract($response->httpVersion),
            $response->headers,
            BodyNormalizer::normalize($response->body, $internalRequest->getMethod())
        );
    }
}

VaKeR 2022