src/ImageStack/ImageBackend/HttpImageBackend.php
protected function httpRequest($url, &$content)
    {
        $client = new Client([
            'allow_redirects' => true,
            'curl' => $this->getOption('curl', []),
        ]);
        try {
            $response = $client->request('GET', $url);
        } catch (RequestException $e) {
            if ($e->hasResponse()) {
                if ($e->getResponse()->getStatusCode() == 404) {
                    throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
                }
            }
            if ($this->getOption('intercept_exception', false)) {
                throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
            } else {
                throw new ImageBackendException(sprintf("Cannot read file : %s", $url), ImageBackendException::CANNOT_READ_FILE, $e);
            }
        }
        $content = (string)($response->getBody());
        $contentType = $response->getHeader('content-type');
        return isset($contentType[0]) ? $contentType[0] : null;
    }
protected function httpRequest($url, &$content)
    {
        $client = new Client([
            'allow_redirects' => true,
            'curl' => $this->getOption('curl', []),
        ]);
        try {
            $response = $client->request('GET', $url);
        } catch (RequestException $e) {
            if ($e->hasResponse()) {
                if ($e->getResponse()->getStatusCode() == 404) {
                    throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
                }
            }
            if ($this->getOption('intercept_exception', false)) {
                throw new ImageNotFoundException(sprintf('Image Not Found : %s', $url), null, $e);
            } else {
                throw new ImageBackendException(sprintf("Cannot read file : %s", $url), ImageBackendException::CANNOT_READ_FILE, $e);
            }
        }
        $content = (string)($response->getBody());
        $contentType = $response->getHeader('content-type');
        return isset($contentType[0]) ? $contentType[0] : null;
    }
protected function httpRequest ( $ url , & $ content ) { $ client = new Client ( [ 'allow_redirects' => true , 'curl' => $ this -> getOption ( 'curl' , [ ] ) , ] ) ; try { $ response = $ client -> request ( 'GET' , $ url ) ; } catch ( RequestException $ e ) { if ( $ e -> hasResponse ( ) ) { if ( $ e -> getResponse ( ) -> getStatusCode ( ) == 404 ) { throw new ImageNotFoundException ( sprintf ( 'Image Not Found : %s' , $ url ) , null , $ e ) ; } } if ( $ this -> getOption ( 'intercept_exception' , false ) ) { throw new ImageNotFoundException ( sprintf ( 'Image Not Found : %s' , $ url ) , null , $ e ) ; } else { throw new ImageBackendException ( sprintf ( "Cannot read file : %s" , $ url ) , ImageBackendException :: CANNOT_READ_FILE , $ e ) ; } } $ content = ( string ) ( $ response -> getBody ( ) ) ; $ contentType = $ response -> getHeader ( 'content-type' ) ; return isset ( $ contentType [ 0 ] ) ? $ contentType [ 0 ] : null ; }
Perform HTTP query.
@param string $url
@param string &$content
@return string|null MIME type
Perform HTTP query .