public static function createResponse(
        callable $handler,
        array $request,
        array $response,
        array $headers,
        $body
    ) {
        if (isset($response['transfer_stats']['url'])) {
            $response['effective_url'] = $response['transfer_stats']['url'];
        }

        if (!empty($headers)) {
            $startLine = explode(' ', array_shift($headers), 3);
            $headerList = Core::headersFromLines($headers);
            $response['headers'] = $headerList;
            $response['version'] = isset($startLine[0]) ? substr($startLine[0], 5) : null;
            $response['status'] = isset($startLine[1]) ? (int) $startLine[1] : null;
            $response['reason'] = isset($startLine[2]) ? $startLine[2] : null;
            $response['body'] = $body;
            Core::rewindBody($response);
        }

        return !empty($response['curl']['errno']) || !isset($response['status'])
            ? self::createErrorResponse($handler, $request, $response)
            : $response;
    }
public static function createResponse(
        callable $handler,
        array $request,
        array $response,
        array $headers,
        $body
    ) {
        if (isset($response['transfer_stats']['url'])) {
            $response['effective_url'] = $response['transfer_stats']['url'];
        }

        if (!empty($headers)) {
            $startLine = explode(' ', array_shift($headers), 3);
            $headerList = Core::headersFromLines($headers);
            $response['headers'] = $headerList;
            $response['version'] = isset($startLine[0]) ? substr($startLine[0], 5) : null;
            $response['status'] = isset($startLine[1]) ? (int) $startLine[1] : null;
            $response['reason'] = isset($startLine[2]) ? $startLine[2] : null;
            $response['body'] = $body;
            Core::rewindBody($response);
        }

        return !empty($response['curl']['errno']) || !isset($response['status'])
            ? self::createErrorResponse($handler, $request, $response)
            : $response;
    }
public static function createResponse ( callable $ handler , array $ request , array $ response , array $ headers , $ body ) { if ( isset ( $ response [ 'transfer_stats' ] [ 'url' ] ) ) { $ response [ 'effective_url' ] = $ response [ 'transfer_stats' ] [ 'url' ] ; } if ( ! empty ( $ headers ) ) { $ startLine = explode ( ' ' , array_shift ( $ headers ) , 3 ) ; $ headerList = Core :: headersFromLines ( $ headers ) ; $ response [ 'headers' ] = $ headerList ; $ response [ 'version' ] = isset ( $ startLine [ 0 ] ) ? substr ( $ startLine [ 0 ] , 5 ) : null ; $ response [ 'status' ] = isset ( $ startLine [ 1 ] ) ? ( int ) $ startLine [ 1 ] : null ; $ response [ 'reason' ] = isset ( $ startLine [ 2 ] ) ? $ startLine [ 2 ] : null ; $ response [ 'body' ] = $ body ; Core :: rewindBody ( $ response ) ; } return ! empty ( $ response [ 'curl' ] [ 'errno' ] ) || ! isset ( $ response [ 'status' ] ) ? self :: createErrorResponse ( $ handler , $ request , $ response ) : $ response ; }
Creates a response hash from a cURL result.

@param callable $handler  Handler that was used.
@param array    $request  Request that sent.
@param array    $response Response hash to update.
@param array    $headers  Headers received during transfer.
@param resource $body     Body fopen response.

@return array
Creates a response hash from a cURL result .