1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-02 11:42:42 +01:00
phorge-phorge/src/aphront/sink/AphrontPHPHTTPSink.php

36 lines
797 B
PHP
Raw Normal View History

<?php
/**
* Concrete HTTP sink which uses "echo" and "header()" to emit data.
*/
final class AphrontPHPHTTPSink extends AphrontHTTPSink {
protected function emitHTTPStatus($code, $message = '') {
if ($code != 200) {
$header = "HTTP/1.0 {$code}";
if (strlen($message)) {
$header .= " {$message}";
}
header($header);
}
}
protected function emitHeader($name, $value) {
header("{$name}: {$value}", $replace = false);
}
protected function emitData($data) {
echo $data;
// Try to push the data to the browser. This has a lot of caveats around
// browser buffering and display behavior, but approximately works most
// of the time.
flush();
}
protected function isWritable() {
return !connection_aborted();
}
}