mirror of
https://github.com/nextcloud/server.git
synced 2026-02-03 20:41:22 -05:00
perf(response): Flush requests early to clients
If not, the response will wait for async actions, e.g. HTTP requests from IClientService, to be finished before returning. This is not desired in many cases with e.g. with notifications. Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
4775ce4266
commit
d4ce68e0f9
2 changed files with 27 additions and 0 deletions
|
|
@ -213,5 +213,10 @@ class App {
|
|||
$io->setOutput($output);
|
||||
}
|
||||
}
|
||||
|
||||
if ($response->getFlushEarly()) {
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ class Response {
|
|||
|
||||
/** @var bool */
|
||||
private $throttled = false;
|
||||
private bool $flushEarly = true;
|
||||
/** @var array */
|
||||
private $throttleMetadata = [];
|
||||
|
||||
|
|
@ -412,4 +413,25 @@ class Response {
|
|||
public function isThrottled() {
|
||||
return $this->throttled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request the response should be flushed to the connected client immediately
|
||||
*
|
||||
* @since 34.0.0
|
||||
*/
|
||||
public function setFlushEarly(bool $flushEarly): void {
|
||||
$this->flushEarly = $flushEarly;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the response should be flushed to the connected client immediately
|
||||
*
|
||||
* If not, the response will wait for async actions, e.g. HTTP requests from
|
||||
* IClientService, to be finished before returning.
|
||||
*
|
||||
* @since 34.0.0
|
||||
*/
|
||||
public function getFlushEarly(): bool {
|
||||
return $this->flushEarly;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue