You are here

public function Client::request in Zircon Profile 8

Same name in this branch
  1. 8 vendor/symfony/browser-kit/Client.php \Symfony\Component\BrowserKit\Client::request()
  2. 8 vendor/guzzlehttp/guzzle/src/Client.php \GuzzleHttp\Client::request()
Same name and namespace in other branches
  1. 8.0 vendor/symfony/browser-kit/Client.php \Symfony\Component\BrowserKit\Client::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 a 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()):

Return value

Crawler

4 calls to Client::request()
Client::click in vendor/symfony/browser-kit/Client.php
Clicks on a given link.
Client::followRedirect in vendor/symfony/browser-kit/Client.php
Follow redirects?
Client::requestFromRequest in vendor/symfony/browser-kit/Client.php
Makes a request from a Request object directly.
Client::submit in vendor/symfony/browser-kit/Client.php
Submits a form.

File

vendor/symfony/browser-kit/Client.php, line 259

Class

Client
Client simulates a browser.

Namespace

Symfony\Component\BrowserKit

Code

public function request($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) {
  if ($this->isMainRequest) {
    $this->redirectCount = 0;
  }
  else {
    ++$this->redirectCount;
  }
  $uri = $this
    ->getAbsoluteUri($uri);
  if (!empty($server['HTTP_HOST'])) {
    $uri = preg_replace('{^(https?\\://)' . preg_quote($this
      ->extractHost($uri)) . '}', '${1}' . $server['HTTP_HOST'], $uri);
  }
  if (isset($server['HTTPS'])) {
    $uri = preg_replace('{^' . parse_url($uri, PHP_URL_SCHEME) . '}', $server['HTTPS'] ? 'https' : 'http', $uri);
  }
  $server = array_merge($this->server, $server);
  if (!$this->history
    ->isEmpty()) {
    $server['HTTP_REFERER'] = $this->history
      ->current()
      ->getUri();
  }
  $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
    ->getStatus();
  if ($status >= 300 && $status < 400) {
    $this->redirect = $this->internalResponse
      ->getHeader('Location');
  }
  else {
    $this->redirect = null;
  }
  if ($this->followRedirects && $this->redirect) {
    return $this->crawler = $this
      ->followRedirect();
  }
  return $this->crawler = $this
    ->createCrawlerFromContent($this->internalRequest
    ->getUri(), $this->internalResponse
    ->getContent(), $this->internalResponse
    ->getHeader('Content-Type'));
}