Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. HttpBrowser.php

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\BrowserKit

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal