Request-Response Cycle¶
Your application requests a resource.
This request includes the url
of the
resource you want to retrieve, the callback
URL where you want the resource to be sent when it has been retrieved
and, optionally, a set of headers
to be sent with the retrieval request.
The response you receive includes a json-encoded string. That’s the request ID. You’ll want to make a note of that somewhere.
+--------------+ +--------------+
| | | |
| | POST http://localhost:8001/ | |
| | url=http://example.com/ | |
| | callback=http://callback.example.com/ | |
| | headers={ | |
| | "User-Agent":"Chrome, honest" | |
| | } | |
| | parameters={ | |
| | "cookies": { | |
| | } | |
| | } | |
| | | |
| | | |
| | | Asynchronous |
| Your | | HTTP |
| application | +--------------------------------------------------------> | retriever |
| | | |
| | | |
| | | |
| | | |
| | HTTP 200 OK | |
| | Content-Type: application/json | |
| | | |
| | "118e35f631be802c41bec5c9dfb0f415" | |
| | <--------------------------------------------------------+ | |
+--------------+ +--------------+
+
Your request to retrieve a resource has been put into a queue. The request will probably be handled quite quickly but not instantly. Some time will pass before your request has completed.
… let’s wait. Something will happen eventually …
Your request completed and was successful. That’s good.
A json-encoded response object is sent in a POST
request to the callback
URL
that you specified in your request.
+-------------+ +--------------+
| | POST http://callback.example.com/ | |
| | { | |
| | "request_id": "118e35f631be802c41b…", | |
| | "status": "success", | |
| | "headers": { | |
| | "content-type": "text/html;" | |
| Your | }, | |
| callback | "content": "PGRvY3R5cGUgaHRtbD4=" | Asynchronous |
| handler | } | HTTP |
| | | Retriever |
| | <---------------------------------------------------------+ | |
+-------------+ +--------------+