<commit_before><?php

namespace Saxulum\HttpClient\Buzz;

use Buzz\Browser;
use Buzz\Message\Request as BuzzRequest;
use Buzz\Message\Response as BuzzResponse;
use Saxulum\HttpClient\HeaderConverter;
use Saxulum\HttpClient\HttpInterface;
use Saxulum\HttpClient\Request;
use Saxulum\HttpClient\Response;

class HttpClient implements HttpInterface
{
    /**
     * @var Browser
     */
    protected $browser;

    /**
     * @param Browser $browser
     */
    public function __construct(Browser $browser = null)
    {
        $this->browser = null !== $browser ? $browser : new Browser();
    }

    /**
     * @param  Request  $request
     * @return Response
     */
    public function request(Request $request)
    {
        $buzzRequest = new BuzzRequest(
            $request->getMethod(),
            $request->getUrl()->getResource(),
            $request->getUrl()->getHost()
        );

        $buzzRequest->setProtocolVersion($request->getProtocolVersion());
        $buzzRequest->setHeaders(HeaderConverter::convertHeaders($request->getHeaders()));
        $buzzRequest->setContent($request->getContent());

        /** @var BuzzResponse $buzzResponse */
        $buzzResponse = $this->browser->send($buzzRequest);

        return new Response(
            (string) $buzzResponse->getProtocolVersion(),
            $buzzResponse->getStatusCode(),
            $buzzResponse->getReasonPhrase(),
            HeaderConverter::convertRawHeaders($buzzResponse->getHeaders()),
            $buzzResponse->getContent()
        );
    }
}<commit_msg>update to beta 3 of the interface<commit_after><?php

namespace Saxulum\HttpClient\Buzz;

use Buzz\Browser;
use Buzz\Message\Request as BuzzRequest;
use Buzz\Message\Response as BuzzResponse;
use Saxulum\HttpClient\HeaderConverter;
use Saxulum\HttpClient\HttpInterface;
use Saxulum\HttpClient\Request;
use Saxulum\HttpClient\Response;

class HttpClient implements HttpInterface
{
    /**
     * @var Browser
     */
    protected $browser;

    /**
     * @param Browser $browser
     */
    public function __construct(Browser $browser = null)
    {
        $this->browser = null !== $browser ? $browser : new Browser();
    }

    /**
     * @param  Request  $request
     * @return Response
     */
    public function request(Request $request)
    {
        $buzzRequest = new BuzzRequest(
            $request->getMethod(),
            $request->getUrl()->getResource(),
            $request->getUrl()->getHost()
        );

        $buzzRequest->setProtocolVersion($request->getProtocolVersion());
        $buzzRequest->setHeaders(HeaderConverter::convertAssociativeToRaw($request->getHeaders()));
        $buzzRequest->setContent($request->getContent());

        /** @var BuzzResponse $buzzResponse */
        $buzzResponse = $this->browser->send($buzzRequest);

        return new Response(
            (string) $buzzResponse->getProtocolVersion(),
            $buzzResponse->getStatusCode(),
            $buzzResponse->getReasonPhrase(),
            HeaderConverter::convertRawToAssociative($buzzResponse->getHeaders()),
            $buzzResponse->getContent()
        );
    }
}
{'fraction_non_alphanumeric': 0.13044861597200128, 'fraction_numerical': 0.0003181673560292714, 'mean_word_length': 2.8576687116564417, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7139036', 'n_tokens_mistral': 863, 'n_tokens_neox': 832, 'n_words': 156}