You are here

public function Client::requestAsync in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/guzzlehttp/guzzle/src/Client.php \GuzzleHttp\Client::requestAsync()

Create and send an asynchronous HTTP request.

Use an absolute path to override the base path of the client, or a relative path to append to the base path of the client. The URL can contain the query string as well. Use an array to provide a URL template and additional variables to use in the URL template expansion.

Parameters

string $method HTTP method:

string|UriInterface $uri URI object or string.:

array $options Request options to apply.:

Return value

PromiseInterface

Overrides ClientInterface::requestAsync

1 call to Client::requestAsync()
Client::__call in vendor/guzzlehttp/guzzle/src/Client.php

File

vendor/guzzlehttp/guzzle/src/Client.php, line 107

Class

Client
@method ResponseInterface get($uri, array $options = []) @method ResponseInterface head($uri, array $options = []) @method ResponseInterface put($uri, array $options = []) @method ResponseInterface post($uri, array $options = []) @method…

Namespace

GuzzleHttp

Code

public function requestAsync($method, $uri = null, array $options = []) {
  $options = $this
    ->prepareDefaults($options);

  // Remove request modifying parameter because it can be done up-front.
  $headers = isset($options['headers']) ? $options['headers'] : [];
  $body = isset($options['body']) ? $options['body'] : null;
  $version = isset($options['version']) ? $options['version'] : '1.1';

  // Merge the URI into the base URI.
  $uri = $this
    ->buildUri($uri, $options);
  if (is_array($body)) {
    $this
      ->invalidBody();
  }
  $request = new Psr7\Request($method, $uri, $headers, $body, $version);

  // Remove the option so that they are not doubly-applied.
  unset($options['headers'], $options['body'], $options['version']);
  return $this
    ->transfer($request, $options);
}