private function createStreamContext($method, array $headers, array $content = array(), array $files = array())
    {
        if (!empty($files)) {
            throw new HttpAdapterException(sprintf('The "%s" does not support files.', __CLASS__));
        }

        $contextOptions = array('http' => array('method' => $method));

        if (!empty($headers)) {
            $contextOptions['http']['header'] = '';

            foreach ($this->fixHeaders($headers) as $header) {
                $contextOptions['http']['header'] .= sprintf("%s\r\n", $header);
            }
        }

        if ($this->getMaxRedirects() > 0) {
            $contextOptions['http']['follow_location'] = 1;
            $contextOptions['http']['max_redirects'] = $this->getMaxRedirects();
        }

        if ($method === 'POST' || $method === 'PUT') {
            $contextOptions['http']['content'] = $this->fixContent($content);
        }

        return stream_context_create($contextOptions);
    }
private function createStreamContext($method, array $headers, array $content = array(), array $files = array())
    {
        if (!empty($files)) {
            throw new HttpAdapterException(sprintf('The "%s" does not support files.', __CLASS__));
        }

        $contextOptions = array('http' => array('method' => $method));

        if (!empty($headers)) {
            $contextOptions['http']['header'] = '';

            foreach ($this->fixHeaders($headers) as $header) {
                $contextOptions['http']['header'] .= sprintf("%s\r\n", $header);
            }
        }

        if ($this->getMaxRedirects() > 0) {
            $contextOptions['http']['follow_location'] = 1;
            $contextOptions['http']['max_redirects'] = $this->getMaxRedirects();
        }

        if ($method === 'POST' || $method === 'PUT') {
            $contextOptions['http']['content'] = $this->fixContent($content);
        }

        return stream_context_create($contextOptions);
    }
private function createStreamContext ( $ method , array $ headers , array $ content = array ( ) , array $ files = array ( ) ) { if ( ! empty ( $ files ) ) { throw new HttpAdapterException ( sprintf ( 'The "%s" does not support files.' , __CLASS__ ) ) ; } $ contextOptions = array ( 'http' => array ( 'method' => $ method ) ) ; if ( ! empty ( $ headers ) ) { $ contextOptions [ 'http' ] [ 'header' ] = '' ; foreach ( $ this -> fixHeaders ( $ headers ) as $ header ) { $ contextOptions [ 'http' ] [ 'header' ] .= sprintf ( "%s\r\n" , $ header ) ; } } if ( $ this -> getMaxRedirects ( ) > 0 ) { $ contextOptions [ 'http' ] [ 'follow_location' ] = 1 ; $ contextOptions [ 'http' ] [ 'max_redirects' ] = $ this -> getMaxRedirects ( ) ; } if ( $ method === 'POST' || $ method === 'PUT' ) { $ contextOptions [ 'http' ] [ 'content' ] = $ this -> fixContent ( $ content ) ; } return stream_context_create ( $ contextOptions ) ; }
Creates the stream context.

@param string $method  The HTTP method.
@param array  $headers The headers.
@param array  $content The content.
@param array  $files   The files.

@throws \Widop\HttpAdapter\HttpAdapterException If there are files (not supported).

@return resource A stream context resource.
Creates the stream context .