private function execute($url, $context)
    {
        if (($stream = @fopen($this->fixUrl($url), 'rb', false, $context)) === false) {
            throw HttpAdapterException::cannotFetchUrl($url, $this->getName(), print_r(error_get_last(), true));
        }

        $metadata = stream_get_meta_data($stream);

        if (preg_match_all('#Location:([^,]+)#', implode(',', $metadata['wrapper_data']), $matches)) {
            $effectiveUrl = trim($matches[1][count($matches[1]) - 1]);
        } else {
            $effectiveUrl = $url;
        }

        $content = stream_get_contents($stream);
        fclose($stream);

        return $this->createResponse(
            isset($metadata['wrapper_data'][0]) ? $this->parseStatusCode($metadata['wrapper_data'][0]) : null,
            $url,
            $metadata['wrapper_data'],
            $content,
            $effectiveUrl
        );
    }
private function execute($url, $context)
    {
        if (($stream = @fopen($this->fixUrl($url), 'rb', false, $context)) === false) {
            throw HttpAdapterException::cannotFetchUrl($url, $this->getName(), print_r(error_get_last(), true));
        }

        $metadata = stream_get_meta_data($stream);

        if (preg_match_all('#Location:([^,]+)#', implode(',', $metadata['wrapper_data']), $matches)) {
            $effectiveUrl = trim($matches[1][count($matches[1]) - 1]);
        } else {
            $effectiveUrl = $url;
        }

        $content = stream_get_contents($stream);
        fclose($stream);

        return $this->createResponse(
            isset($metadata['wrapper_data'][0]) ? $this->parseStatusCode($metadata['wrapper_data'][0]) : null,
            $url,
            $metadata['wrapper_data'],
            $content,
            $effectiveUrl
        );
    }
private function execute ( $ url , $ context ) { if ( ( $ stream = @ fopen ( $ this -> fixUrl ( $ url ) , 'rb' , false , $ context ) ) === false ) { throw HttpAdapterException :: cannotFetchUrl ( $ url , $ this -> getName ( ) , print_r ( error_get_last ( ) , true ) ) ; } $ metadata = stream_get_meta_data ( $ stream ) ; if ( preg_match_all ( '#Location:([^,]+)#' , implode ( ',' , $ metadata [ 'wrapper_data' ] ) , $ matches ) ) { $ effectiveUrl = trim ( $ matches [ 1 ] [ count ( $ matches [ 1 ] ) - 1 ] ) ; } else { $ effectiveUrl = $ url ; } $ content = stream_get_contents ( $ stream ) ; fclose ( $ stream ) ; return $ this -> createResponse ( isset ( $ metadata [ 'wrapper_data' ] [ 0 ] ) ? $ this -> parseStatusCode ( $ metadata [ 'wrapper_data' ] [ 0 ] ) : null , $ url , $ metadata [ 'wrapper_data' ] , $ content , $ effectiveUrl ) ; }
Calls an URL given a context.

@param string   $url     An url.
@param resource $context A resource (created from stream_context_create).

@throws \Widop\HttpAdapterBundle\Exception\HttpAdapterException If an error occured.

@return @return \Widop\HttpAdapter\HttpResponse The response.
Calls an URL given a context .