function HttpBrowser::getHeaders
1 call to HttpBrowser::getHeaders()
- HttpBrowser::doRequest in vendor/
symfony/ browser-kit/ HttpBrowser.php
File
-
vendor/
symfony/ browser-kit/ HttpBrowser.php, line 111
Class
- HttpBrowser
- An implementation of a browser using the HttpClient component to make real HTTP requests.
Namespace
Symfony\Component\BrowserKitCode
protected function getHeaders(Request $request) : array {
$headers = [];
foreach ($request->getServer() as $key => $value) {
$key = strtolower(str_replace('_', '-', $key));
$contentHeaders = [
'content-length' => true,
'content-md5' => true,
'content-type' => true,
];
if (str_starts_with($key, 'http-')) {
$headers[substr($key, 5)] = $value;
}
elseif (isset($contentHeaders[$key])) {
// CONTENT_* are not prefixed with HTTP_
$headers[$key] = $value;
}
}
$cookies = [];
foreach ($this->getCookieJar()
->allRawValues($request->getUri()) as $name => $value) {
$cookies[] = $name . '=' . $value;
}
if ($cookies) {
$headers['cookie'] = implode('; ', $cookies);
}
return $headers;
}