Warning: Cannot modify header information - headers already sent by (output started at /www/wwwroot/sbboke.com/wp-content/plugins/wordpress-seo/src/integrations/front-end-integration.php:409) in /www/wwwroot/sbboke.com/wp-content/themes/pacify/content-single.php on line 5

在magento中的Zend_Http_Response的getRawBody()和getBody()方法之间的区别?

$ response-> getBody()和$ response-> getRawBody()之间的区别

getRawBody() 按原样返回http响应的主体。

getBody()调整某些标题,即解压缩使用gzip或deflate内容编码标头发送的内容。或者分块传输编码头。

最简单的方法是将这些问题简单地看一下代码。也是一个很棒的学习经历。编译代码是为了简洁起见。

public function getRawBody()
{
    return $this->body;
}

public function getBody()
{
    $body = '';

    // Decode the body if it was transfer-encoded
    switch (strtolower($this->getHeader('transfer-encoding'))) {
        case 'chunked':
            // Handle chunked body
            break;
        // No transfer encoding, or unknown encoding extension:
        default:
            // return body as is
            break;
    }

    // Decode any content-encoding (gzip or deflate) if needed
    switch (strtolower($this->getHeader('content-encoding'))) { 
        case 'gzip':
             // Handle gzip encoding
            break;
        case 'deflate':
            // Handle deflate encoding
            break;
        default:
            break;
    }

    return $body;
}

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论