src/VCR/Util/CurlHelper.php
public static function handleOutput(Response $response, array $curlOptions, $ch)
    {
        // If there is a header function set, feed the http status and headers to it.
        if (isset($curlOptions[CURLOPT_HEADERFUNCTION])) {
            $headerList = array(HttpUtil::formatAsStatusString($response));
            $headerList = array_merge($headerList, HttpUtil::formatHeadersForCurl($response->getHeaders()));
            $headerList[] = '';
            foreach ($headerList as $header) {
                call_user_func($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header);
            }
        }

        $body = $response->getBody();

        if (!empty($curlOptions[CURLOPT_HEADER])) {
            $body = HttpUtil::formatAsStatusWithHeadersString($response) . $body;
        }

        if (isset($curlOptions[CURLOPT_WRITEFUNCTION])) {
            call_user_func($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body);
        } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && $curlOptions[CURLOPT_RETURNTRANSFER] == true) {
            return $body;
        } elseif (isset($curlOptions[CURLOPT_FILE])) {
            $fp = $curlOptions[CURLOPT_FILE];
            fwrite($fp, $body);
            fflush($fp);
        } else {
            echo $body;
        }
    }
public static function handleOutput(Response $response, array $curlOptions, $ch)
    {
        // If there is a header function set, feed the http status and headers to it.
        if (isset($curlOptions[CURLOPT_HEADERFUNCTION])) {
            $headerList = array(HttpUtil::formatAsStatusString($response));
            $headerList = array_merge($headerList, HttpUtil::formatHeadersForCurl($response->getHeaders()));
            $headerList[] = '';
            foreach ($headerList as $header) {
                call_user_func($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header);
            }
        }

        $body = $response->getBody();

        if (!empty($curlOptions[CURLOPT_HEADER])) {
            $body = HttpUtil::formatAsStatusWithHeadersString($response) . $body;
        }

        if (isset($curlOptions[CURLOPT_WRITEFUNCTION])) {
            call_user_func($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body);
        } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && $curlOptions[CURLOPT_RETURNTRANSFER] == true) {
            return $body;
        } elseif (isset($curlOptions[CURLOPT_FILE])) {
            $fp = $curlOptions[CURLOPT_FILE];
            fwrite($fp, $body);
            fflush($fp);
        } else {
            echo $body;
        }
    }
public static function handleOutput ( Response $ response , array $ curlOptions , $ ch ) { // If there is a header function set, feed the http status and headers to it. if ( isset ( $ curlOptions [ CURLOPT_HEADERFUNCTION ] ) ) { $ headerList = array ( HttpUtil :: formatAsStatusString ( $ response ) ) ; $ headerList = array_merge ( $ headerList , HttpUtil :: formatHeadersForCurl ( $ response -> getHeaders ( ) ) ) ; $ headerList [ ] = '' ; foreach ( $ headerList as $ header ) { call_user_func ( $ curlOptions [ CURLOPT_HEADERFUNCTION ] , $ ch , $ header ) ; } } $ body = $ response -> getBody ( ) ; if ( ! empty ( $ curlOptions [ CURLOPT_HEADER ] ) ) { $ body = HttpUtil :: formatAsStatusWithHeadersString ( $ response ) . $ body ; } if ( isset ( $ curlOptions [ CURLOPT_WRITEFUNCTION ] ) ) { call_user_func ( $ curlOptions [ CURLOPT_WRITEFUNCTION ] , $ ch , $ body ) ; } elseif ( isset ( $ curlOptions [ CURLOPT_RETURNTRANSFER ] ) && $ curlOptions [ CURLOPT_RETURNTRANSFER ] == true ) { return $ body ; } elseif ( isset ( $ curlOptions [ CURLOPT_FILE ] ) ) { $ fp = $ curlOptions [ CURLOPT_FILE ] ; fwrite ( $ fp , $ body ) ; fflush ( $ fp ) ; } else { echo $ body ; } }
Outputs a response depending on the set cURL option.

The response body can be written to a file, returned, echoed or
passed to a custom function.

The response header might be passed to a custom function.

@param  Response $response    Response which contains the response body.
@param  array    $curlOptions cURL options which are not stored within the Response.
@param  resource $ch          cURL handle to add headers if needed.

@return null|string
Outputs a response depending on the set cURL option .