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

Breadcrumb

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

function AbstractBrowser::request

Calls a URI.

Parameters

string $method The request method:

string $uri The URI to fetch:

array $parameters The Request parameters:

array $files The files:

array $server The server parameters (HTTP headers are referenced with an HTTP_ prefix as PHP does):

string $content The raw body data:

bool $changeHistory Whether to update the history or not (only used internally for back(), forward(), and reload()):

6 calls to AbstractBrowser::request()
AbstractBrowser::click in vendor/symfony/browser-kit/AbstractBrowser.php
Clicks on a given link.
AbstractBrowser::followRedirect in vendor/symfony/browser-kit/AbstractBrowser.php
Follow redirects?
AbstractBrowser::jsonRequest in vendor/symfony/browser-kit/AbstractBrowser.php
Converts the request parameters into a JSON string and uses it as request content.
AbstractBrowser::requestFromRequest in vendor/symfony/browser-kit/AbstractBrowser.php
Makes a request from a Request object directly.
AbstractBrowser::submit in vendor/symfony/browser-kit/AbstractBrowser.php
Submits a form.

... See full list

File

vendor/symfony/browser-kit/AbstractBrowser.php, line 335

Class

AbstractBrowser
Simulates a browser.

Namespace

Symfony\Component\BrowserKit

Code

public function request(string $method, string $uri, array $parameters = [], array $files = [], array $server = [], ?string $content = null, bool $changeHistory = true) : Crawler {
    if ($this->isMainRequest) {
        $this->redirectCount = 0;
    }
    else {
        ++$this->redirectCount;
    }
    $originalUri = $uri;
    $uri = $this->getAbsoluteUri($uri);
    $server = array_merge($this->server, $server);
    if (!empty($server['HTTP_HOST']) && !parse_url($originalUri, \PHP_URL_HOST)) {
        $uri = preg_replace('{^(https?\\://)' . preg_quote($this->extractHost($uri)) . '}', '${1}' . $server['HTTP_HOST'], $uri);
    }
    if (isset($server['HTTPS']) && !parse_url($originalUri, \PHP_URL_SCHEME)) {
        $uri = preg_replace('{^' . parse_url($uri, \PHP_URL_SCHEME) . '}', $server['HTTPS'] ? 'https' : 'http', $uri);
    }
    if (!isset($server['HTTP_REFERER']) && !$this->history
        ->isEmpty()) {
        $server['HTTP_REFERER'] = $this->history
            ->current()
            ->getUri();
    }
    if (empty($server['HTTP_HOST'])) {
        $server['HTTP_HOST'] = $this->extractHost($uri);
    }
    $server['HTTPS'] = 'https' === parse_url($uri, \PHP_URL_SCHEME);
    $this->internalRequest = new Request($uri, $method, $parameters, $files, $this->cookieJar
        ->allValues($uri), $server, $content);
    $this->request = $this->filterRequest($this->internalRequest);
    if (true === $changeHistory) {
        $this->history
            ->add($this->internalRequest);
    }
    if ($this->insulated) {
        $this->response = $this->doRequestInProcess($this->request);
    }
    else {
        $this->response = $this->doRequest($this->request);
    }
    $this->internalResponse = $this->filterResponse($this->response);
    $this->cookieJar
        ->updateFromResponse($this->internalResponse, $uri);
    $status = $this->internalResponse
        ->getStatusCode();
    if ($status >= 300 && $status < 400) {
        $this->redirect = $this->internalResponse
            ->getHeader('Location');
    }
    else {
        $this->redirect = null;
    }
    if ($this->followRedirects && $this->redirect) {
        $this->redirects[serialize($this->history
            ->current())] = true;
        return $this->crawler = $this->followRedirect();
    }
    $this->crawler = $this->createCrawlerFromContent($this->internalRequest
        ->getUri(), $this->internalResponse
        ->getContent(), $this->internalResponse
        ->getHeader('Content-Type') ?? '');
    // Check for meta refresh redirect
    if ($this->followMetaRefresh && null !== ($redirect = $this->getMetaRefreshUrl())) {
        $this->redirect = $redirect;
        $this->redirects[serialize($this->history
            ->current())] = true;
        $this->crawler = $this->followRedirect();
    }
    return $this->crawler;
}

API Navigation

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