Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add promise resolution type, closes #79
  • Loading branch information
sagikazarmark authored and Márk Sági-Kazár committed Jan 26, 2016
commit b17faa4bda3e602b84ea6712392b0e554083fcf7
15 changes: 11 additions & 4 deletions components/promise.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
Promise
=======

When sending asynchronous HTTP requests, a promise is returned. The promise acts
as a proxy for the response or error result, which is not yet known.
A promise represents a single result of an asynchronous operation.
It is not necessarily available at a specific time, but should become in the future.

The PHP-HTTP promise follows the `Promises/A+`_ standard.

.. note::
Expand All @@ -13,8 +14,11 @@ The PHP-HTTP promise follows the `Promises/A+`_ standard.
Asynchronous requests
---------------------

Asynchronous requests enable non-blocking HTTP operations. To execute such a
request with HTTPlug::
Asynchronous requests enable non-blocking HTTP operations.
When sending asynchronous HTTP requests, a promise is returned. The promise acts
as a proxy for the response or error result, which is not yet known.

To execute such a request with HTTPlug::

$request = $messageFactory->createRequest('GET', 'http://php-http.org');

Expand All @@ -27,6 +31,9 @@ request with HTTPlug::

See :ref:`message-factory` on how to use message factories.

Although the promise itself is not restricted to resolve a specific result type,
in HTTP context it resolves a PSR-7 ``Psr\Http\Message\ResponseInterface`` or fails with an ``Http\Client\Exception``.

Wait
----

Expand Down