From b17faa4bda3e602b84ea6712392b0e554083fcf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rk=20S=C3=A1gi-Kaz=C3=A1r?= Date: Mon, 25 Jan 2016 23:34:42 +0100 Subject: [PATCH] Add promise resolution type, closes #79 --- components/promise.rst | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/components/promise.rst b/components/promise.rst index aff793a..04a92c8 100644 --- a/components/promise.rst +++ b/components/promise.rst @@ -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:: @@ -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'); @@ -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 ----