Applications are invoked as soon as headers are received and before entity body data is parsed. The $request->body instance allows applications to await receipt of the full body (buffer) or stream it in chunks as it arrives. Buffering Example: $responder = function(Request $request, Response $response) { $bufferedBody = yield $request->getBody(); $response->send("Echoing back the request body: {$bufferedBody}"); }; Streaming Example: $responder = function(Request $request, Response $response) { $payload = ""; $body = $request->getBody() while (yield $body->valid()) { $payload .= $body->consume(); } $response->send("Echoing back the request body: {$payload}"); };
Inheritance: extends Amp\PromiseStream, implements Amp\Promise
Ejemplo n.º 1
0
 public function __construct(Promise $promise, Promise $metadata)
 {
     parent::__construct($promise);
     $this->metadata = $metadata;
     $this->valid = $this->valid();
 }