Skip to content

Commit

Permalink
Simplify flush() declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
thekid committed May 19, 2024
1 parent a977472 commit 8edfd2e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/main/php/web/Response.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,16 +136,15 @@ public function flushing(callable $function) {
/**
* Flushes response
*
* @param web.io.Output $output
* @return void
* @throws lang.IllegalStateException
*/
public function flush($output= null) {
public function flush() {
if ($this->flushed) {
throw new IllegalStateException('Response already flushed');
}

$this->begin($output ?: $this->output);
$this->begin($this->output);
}

/**
Expand All @@ -172,16 +171,21 @@ public function end() {
*
* @param int $size If omitted, uses chunked transfer encoding
* @return io.streams.OutputStream
* @throws lang.IllegalStateException
*/
public function stream($size= null) {
if ($this->flushed) {
throw new IllegalStateException('Response already flushed');
}

if (null === $size) {
$output= $this->output->stream();
} else {
$this->headers['Content-Length']= [$size];
$output= $this->output;
}

$this->flush($output);
$this->begin($output);
return $output;
}

Expand Down

0 comments on commit 8edfd2e

Please sign in to comment.