async-plugin.rst 754 B

123456789101112131415161718
  1. ============
  2. Async plugin
  3. ============
  4. The AsyncPlugin allows you to send requests that do not wait on a response. This is handled through cURL by utilizing
  5. the progress event. When a request has sent all of its data to the remote server, Guzzle adds a 1ms timeout on the
  6. request and instructs cURL to not download the body of the response. The async plugin then catches the exception and
  7. adds a mock response to the request, along with an X-Guzzle-Async header to let you know that the response was not
  8. fully downloaded.
  9. .. code-block:: php
  10. use Guzzle\Http\Client;
  11. use Guzzle\Plugin\Async\AsyncPlugin;
  12. $client = new Client('http://www.example.com');
  13. $client->addSubscriber(new AsyncPlugin());
  14. $response = $client->get()->send();