Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/aphront/sink/AphrontPHPHTTPSink.php
12249 views
1
<?php
2
3
/**
4
* Concrete HTTP sink which uses "echo" and "header()" to emit data.
5
*/
6
final class AphrontPHPHTTPSink extends AphrontHTTPSink {
7
8
protected function emitHTTPStatus($code, $message = '') {
9
if ($code != 200) {
10
$header = "HTTP/1.0 {$code}";
11
if (strlen($message)) {
12
$header .= " {$message}";
13
}
14
header($header);
15
}
16
}
17
18
protected function emitHeader($name, $value) {
19
header("{$name}: {$value}", $replace = false);
20
}
21
22
protected function emitData($data) {
23
echo $data;
24
25
// NOTE: We don't call flush() here because it breaks HTTPS under Apache.
26
// See T7620 for discussion. Even without an explicit flush, PHP appears to
27
// have reasonable behavior here: the echo will block if internal buffers
28
// are full, and data will be sent to the client once enough of it has
29
// been buffered.
30
}
31
32
protected function isWritable() {
33
return !connection_aborted();
34
}
35
36
}
37
38