From c7dc59f9c40359f11fea7b787ded7b566dbe0e5a Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 23 Mar 2015 09:09:45 -0700 Subject: [PATCH] Don't call flush() when emitting responses Summary: Fixes T7620. I don't fully understand exactly what's going on here, but we don't actually need to call `flush()`. Test Plan: - Put timing code around the `echo`. - Made a fake page that emitted a lot of data. - Saw the `echo` block proportionate to data size under `curl --limit-rate ...`. - See T7620. - Downloaded a large file, got a reasonable progress bar and no obvious memory use issues. Reviewers: btrahan Reviewed By: btrahan Subscribers: jlarouche, rbalik, epriestley Maniphest Tasks: T7620 Differential Revision: https://secure.phabricator.com/D12127 --- src/aphront/sink/AphrontPHPHTTPSink.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/aphront/sink/AphrontPHPHTTPSink.php b/src/aphront/sink/AphrontPHPHTTPSink.php index 2504aea037..4953b6e610 100644 --- a/src/aphront/sink/AphrontPHPHTTPSink.php +++ b/src/aphront/sink/AphrontPHPHTTPSink.php @@ -22,10 +22,11 @@ final class AphrontPHPHTTPSink extends AphrontHTTPSink { 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(); + // NOTE: We don't call flush() here because it breaks HTTPS under Apache. + // See T7620 for discussion. Even without an explicit flush, PHP appears to + // have reasonable behavior here: the echo will block if internal buffers + // are full, and data will be sent to the client once enough of it has + // been buffered. } protected function isWritable() {