问题描述
在响应类的Zend Framework中,有两个不同的数组用于存储标头: _headers []
和 _headersRaw []
。并且有适当的方法来设置每一个:
In Zend Framework in Response Class there are two different arrays for storing headers: _headers[]
and _headersRaw[]
. And there are appropriate methods for setting each one:
setHeader(),getHeaders(),clearHeader()
和
setRawHeader(),getRawHeaders(),clearRawHeaders()
。
拥有标题和原始标题的原因是什么?实际上每个标题都有一些特殊用法吗?
What is the reason to have "header" and "raw header"? Is there some special kind of usage in practice for each of these headers?
推荐答案
使用setHeader设置关键值对而不用担心格式化例如
using setHeader you set key vale pair without worrying about there formatting e.g
$this->getResponse()->setHeader('Content-type','json');
而在setRawHeader()的情况下,你将整个/完整的标题放在正确的格式化
while in case of setRawHeader() you put the whole/full header as it is with proper formating
这篇关于什么是“原始HTTP标头”? “HTTP标头”之间的区别是什么?和“原始HTTP标题”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!