public function send($method, array $headers = [], $content = null, $protocolVersion = '1.1')
    {

        $headers = $this->addCredentials($headers);

        $this->callBeforeListeners('send', [$this->url, $method, &$headers]);

        // We have to recreate the stream every time
        $this->close();

        $header = implode("\r\n", $headers);
        $stream = $this->createHttpStream($method, $header, $content, $protocolVersion);

        $this->stream = $stream;

        // Currently only stream-less connections are supported
        $raw = $stream->toString();

        list($responseHeader, $content) = $this->parseMessage($raw);

        $response = new Response($responseHeader, $content);
        $response->setRaw($raw);

        $this->callAfterListeners('send', [$this->url, $method, &$headers, $response]);

        $this->close();

        return $response;

    }
public function send($method, array $headers = [], $content = null, $protocolVersion = '1.1')
    {

        $headers = $this->addCredentials($headers);

        $this->callBeforeListeners('send', [$this->url, $method, &$headers]);

        // We have to recreate the stream every time
        $this->close();

        $header = implode("\r\n", $headers);
        $stream = $this->createHttpStream($method, $header, $content, $protocolVersion);

        $this->stream = $stream;

        // Currently only stream-less connections are supported
        $raw = $stream->toString();

        list($responseHeader, $content) = $this->parseMessage($raw);

        $response = new Response($responseHeader, $content);
        $response->setRaw($raw);

        $this->callAfterListeners('send', [$this->url, $method, &$headers, $response]);

        $this->close();

        return $response;

    }
public function send ( $ method , array $ headers = [ ] , $ content = null , $ protocolVersion = '1.1' ) { $ headers = $ this -> addCredentials ( $ headers ) ; $ this -> callBeforeListeners ( 'send' , [ $ this -> url , $ method , & $ headers ] ) ; // We have to recreate the stream every time $ this -> close ( ) ; $ header = implode ( "\r\n" , $ headers ) ; $ stream = $ this -> createHttpStream ( $ method , $ header , $ content , $ protocolVersion ) ; $ this -> stream = $ stream ; // Currently only stream-less connections are supported $ raw = $ stream -> toString ( ) ; list ( $ responseHeader , $ content ) = $ this -> parseMessage ( $ raw ) ; $ response = new Response ( $ responseHeader , $ content ) ; $ response -> setRaw ( $ raw ) ; $ this -> callAfterListeners ( 'send' , [ $ this -> url , $ method , & $ headers , $ response ] ) ; $ this -> close ( ) ; return $ response ; }
Send a http request with file_file_get_contents.

@param string      $method
@param array       $headers (optional)
@param null|string $content
@param string      $protocolVersion (default: '1.1')

@return Response
Send a http request with file_file_get_contents .