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()
and
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?
Raw means that the header is not URL-encoded, whereas if the word "raw" is omitted, the header is encoded. For example: $header = 'http://www.mywebsite.com?
The Raw HTTP action sends a HTTP request to a web server. How the response is treated depends on the method, but in general the status code and the response headers are returned in variables defined as part of the page load options.
HTTP headers are the name or value pairs that are displayed in the request and response messages of message headers for Hypertext Transfer Protocol (HTTP). Usually, the header name and the value are separated by a single colon. HTTP headers are an integral part of HTTP requests and responses.
PHP | header() Function. The header() function is an inbuilt function in PHP which is used to send a raw HTTP header. The HTTP functions are those functions which manipulate information sent to the client or browser by the Web server, before any other output has been sent.
using setHeader you set key vale pair without worrying about there formatting e.g
$this->getResponse()->setHeader('Content-type','json');
while in case of setRawHeader() you put the whole/full header as it is with proper formating
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With