Headers
Both request and response messages contain HTTP headers.
Complex Headers
Some headers contain additional key value pair information. For example, Link headers contain a link and several key value pairs:
<http://foo.com>; rel="thing"; type="image/jpeg"
Guzzle provides a convenience feature that can be used to parse these types of headers:
use GuzzleHttp\Message\Request;
$request = new Request('GET', '/', [
'Link' => '<http:/.../front.jpeg>; rel="front"; type="image/jpeg"'
]);
$parsed = Request::parseHeader($request, 'Link');
var_export($parsed);
Will output:
array (
0 =>
array (
0 => '<http:/.../front.jpeg>',
'rel' => 'front',
'type' => 'image/jpeg',
),
)
The result contains a hash of key value pairs. Header values that have no key (i.e., the link) are indexed numerically while headers parts that form a key value pair are added as a key value pair.
See Request and Response Headers for information on how the headers of a request and response can be accessed and modified.