public function execute(Request $request) : Response
    {
        $host = $request->getHost();
        $socket = new ClientSocket($host, 80);
        $socket->connect();
        $communicator = $socket->getCommunicator();
        $communicator->write($request);
        $communicator->writeLine('');$communicator->writeLine('');
        
        $headers = new Headers();
        $body = ''; 
        
        $headerLine = true;

        $statusLine = $communicator->read(1024, PHP_NORMAL_READ);
        while($line = $communicator->read(5000, PHP_NORMAL_READ)){

            if ($headerLine && $line === PHP_EOL) {
                continue;
            }

            if ($headerLine && ($line === "\r" || $line === PHP_EOL)) {
                $headerLine = false;
                continue;
            }

            if ($headerLine) {
                $headers->add(Header::createFromString($line));
            }else{
                $body .= $line;
            }

        }

        return new Response($body, 200, $headers);
    }
public function execute(Request $request) : Response
    {
        $host = $request->getHost();
        $socket = new ClientSocket($host, 80);
        $socket->connect();
        $communicator = $socket->getCommunicator();
        $communicator->write($request);
        $communicator->writeLine('');$communicator->writeLine('');
        
        $headers = new Headers();
        $body = ''; 
        
        $headerLine = true;

        $statusLine = $communicator->read(1024, PHP_NORMAL_READ);
        while($line = $communicator->read(5000, PHP_NORMAL_READ)){

            if ($headerLine && $line === PHP_EOL) {
                continue;
            }

            if ($headerLine && ($line === "\r" || $line === PHP_EOL)) {
                $headerLine = false;
                continue;
            }

            if ($headerLine) {
                $headers->add(Header::createFromString($line));
            }else{
                $body .= $line;
            }

        }

        return new Response($body, 200, $headers);
    }
public function execute ( Request $ request ) : Response { $ host = $ request -> getHost ( ) ; $ socket = new ClientSocket ( $ host , 80 ) ; $ socket -> connect ( ) ; $ communicator = $ socket -> getCommunicator ( ) ; $ communicator -> write ( $ request ) ; $ communicator -> writeLine ( '' ) ; $ communicator -> writeLine ( '' ) ; $ headers = new Headers ( ) ; $ body = '' ; $ headerLine = true ; $ statusLine = $ communicator -> read ( 1024 , PHP_NORMAL_READ ) ; while ( $ line = $ communicator -> read ( 5000 , PHP_NORMAL_READ ) ) { if ( $ headerLine && $ line === PHP_EOL ) { continue ; } if ( $ headerLine && ( $ line === "\r" || $ line === PHP_EOL ) ) { $ headerLine = false ; continue ; } if ( $ headerLine ) { $ headers -> add ( Header :: createFromString ( $ line ) ) ; } else { $ body .= $ line ; } } return new Response ( $ body , 200 , $ headers ) ; }
Executes a http request
on success a Response object will be returned

@param Request $request
@return Response
Executes a http request on success a Response object will be returned