File Manager Lite
Dir:
/home/codewavebd/public_html/vendor/symfony/http-foundation
Upload
[..]
AcceptHeaderItem.php (3.16 KB)
Edit
Rename
Del
CHANGELOG.md (22.02 KB)
Edit
Rename
Del
Cookie.php (11.53 KB)
Edit
Rename
Del
EventStreamResponse.php (2.88 KB)
Edit
Rename
Del
Exception/
Rename
Del
File/
Rename
Del
HeaderBag.php (6.94 KB)
Edit
Rename
Del
InputBag.php (5.26 KB)
Edit
Rename
Del
IpUtils.php (9.34 KB)
Edit
Rename
Del
JsonResponse.php (6.45 KB)
Edit
Rename
Del
LICENSE (1.04 KB)
Edit
Rename
Del
ParameterBag.php (8.03 KB)
Edit
Rename
Del
README.md (526 B)
Edit
Rename
Del
RateLimiter/
Rename
Del
RedirectResponse.php (2.57 KB)
Edit
Rename
Del
RequestMatcher/
Rename
Del
Response.php (39.6 KB)
Edit
Rename
Del
ResponseHeaderBag.php (7.79 KB)
Edit
Rename
Del
ServerBag.php (3.92 KB)
Edit
Rename
Del
Session/
Rename
Del
StreamedJsonResponse.php (5.65 KB)
Edit
Rename
Del
Test/
Rename
Del
UriSigner.php (7.53 KB)
Edit
Rename
Del
UrlHelper.php (3.05 KB)
Edit
Rename
Del
composer.json (1.33 KB)
Edit
Rename
Del
redisconfig.php (0 B)
Edit
Rename
Del
Edit: EventStreamResponse.php
<?php /* * This file is part of the Symfony package. * * (c) Fabien Potencier <fabien@symfony.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\HttpFoundation; /** * Represents a streaming HTTP response for sending server events * as part of the Server-Sent Events (SSE) streaming technique. * * To broadcast events to multiple users at once, for long-running * connections and for high-traffic websites, prefer using the Mercure * Symfony Component, which relies on Software designed for these use * cases: https://symfony.com/doc/current/mercure.html * * @see ServerEvent * * @author Yonel Ceruto <open@yceruto.dev> * * Example usage: * * return new EventStreamResponse(function () { * yield new ServerEvent(time()); * * sleep(1); * * yield new ServerEvent(time()); * }); */ class EventStreamResponse extends StreamedResponse { /** * @param int|null $retry The number of milliseconds the client should wait * before reconnecting in case of network failure */ public function __construct(?callable $callback = null, int $status = 200, array $headers = [], private ?int $retry = null) { $headers += [ 'Connection' => 'keep-alive', 'Content-Type' => 'text/event-stream', 'Cache-Control' => 'private, no-cache, no-store, must-revalidate, max-age=0', 'X-Accel-Buffering' => 'no', 'Pragma' => 'no-cache', 'Expires' => '0', ]; parent::__construct($callback, $status, $headers); } public function setCallback(callable $callback): static { if ($this->callback) { return parent::setCallback($callback); } $this->callback = function () use ($callback) { if (is_iterable($events = $callback($this))) { foreach ($events as $event) { $this->sendEvent($event); if (connection_aborted()) { break; } } } }; return $this; } /** * Sends a server event to the client. * * @return $this */ public function sendEvent(ServerEvent $event): static { if ($this->retry > 0 && !$event->getRetry()) { $event->setRetry($this->retry); } foreach ($event as $part) { echo $part; if (!\in_array(\PHP_SAPI, ['cli', 'phpdbg', 'embed'], true)) { static::closeOutputBuffers(0, true); flush(); } } return $this; } public function getRetry(): ?int { return $this->retry; } public function setRetry(int $retry): void { $this->retry = $retry; } }
Simpan