1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-03-02 15:39:36 +01:00
phorge-phorge/src/aphront/sink/AphrontIsolatedHTTPSink.php
epriestley 81d88985a0 Prepare file responses for streaming chunks
Summary:
Ref T7149. This still buffers the whole file, but is reaaaaal close to not doing that.

Allow Responses to be streamed, and rewrite the range stuff in the FileResponse so it does not rely on having the entire content available.

Test Plan:
  - Artificially slowed down downloads, suspended/resumed them (works in chrome, not so much in Safari/Firefox?)
  - Played sounds in Safari/Chrome.
  - Viewed a bunch of pages and files in every browser.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: joshuaspence, epriestley

Maniphest Tasks: T7149

Differential Revision: https://secure.phabricator.com/D12072
2015-03-14 08:29:12 -07:00

40 lines
703 B
PHP

<?php
/**
* Isolated HTTP sink for testing.
*/
final class AphrontIsolatedHTTPSink extends AphrontHTTPSink {
private $status;
private $headers;
private $data;
protected function emitHTTPStatus($code, $message = '') {
$this->status = $code;
}
protected function emitHeader($name, $value) {
$this->headers[] = array($name, $value);
}
protected function emitData($data) {
$this->data .= $data;
}
protected function isWritable() {
return true;
}
public function getEmittedHTTPStatus() {
return $this->status;
}
public function getEmittedHeaders() {
return $this->headers;
}
public function getEmittedData() {
return $this->data;
}
}