You are here

public function Client::requestAsync in Lockr 7.3

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 109

Class

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

Namespace

GuzzleHttp

Code

public function requestAsync($method, $uri = '', 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);
}