Aerys\Response::stream PHP Метод

stream() публичный Метод

This method may be repeatedly called to stream the response body. Applications that can afford to buffer an entire response in memory or can wait for all body data to generate may use Response::end() to output the entire response in a single call. Note: Headers are sent upon the first invocation of Response::stream().
public stream ( string $partialBodyChunk ) : Amp\Promise
$partialBodyChunk string A portion of the response entity body
Результат Amp\Promise to be succeeded whenever local buffers aren't full
    public function stream(string $partialBodyChunk) : \Amp\Promise;

Usage Example

Пример #1
0
 private function sendMultiRange($handle, Response $response, $fileInfo, $range) : \Generator
 {
     foreach ($range->ranges as list($startPos, $endPos)) {
         $header = sprintf("--%s\r\nContent-Type: %s\r\nContent-Range: bytes %d-%d/%d\r\n\r\n", $range->boundary, $range->contentType, $startPos, $endPos, $fileInfo->size);
         $response->stream($header);
         yield from $this->sendSingleRange($handle, $response, $startPos, $endPos);
         $response->stream("\r\n");
     }
     $response->stream("--{$range->boundary}--");
 }
All Usage Examples Of Aerys\Response::stream