function 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. See \GuzzleHttp\RequestOptions.:
Overrides ClientTrait::requestAsync
1 call to Client::requestAsync()
- Client::__call in vendor/
guzzlehttp/ guzzle/ src/ Client.php
File
-
vendor/
guzzlehttp/ guzzle/ src/ Client.php, line 153
Class
- Client
- @final
Namespace
GuzzleHttpCode
public function requestAsync(string $method, $uri = '', array $options = []) : PromiseInterface {
$options = $this->prepareDefaults($options);
// Remove request modifying parameter because it can be done up-front.
$headers = $options['headers'] ?? [];
$body = $options['body'] ?? null;
$version = $options['version'] ?? '1.1';
// Merge the URI into the base URI.
$uri = $this->buildUri(Psr7\Utils::uriFor($uri), $options);
if (\is_array($body)) {
throw $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);
}