mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
If HTTP response headers are already sent, don't fiddle with "zlib.output_compression"
Summary: We write some synthetic HTTP responses inside unit tests. Some responses have an indirect side effect of adjusting "zlib.output_compression", but this adjustment fails if headers have already been output. From a CLI context, headers appear to count as already-output after we write anything to stdout: ``` <?php echo headers_sent() ? "Y" : "N"; echo "\n"; echo headers_sent() ? "Y" : "N"; echo "\n"; ``` This script prints "N", then "Y". Recently, the default severity of warnings was increased in libphutil; this has been a long-standing warning but now causes test failures. This behavior is sort of silly but the whole thing is kind of moot anyway. Just skip it if "headers_sent()" is true. Test Plan: Ran "arc unit --everything", got clean results. Differential Revision: https://secure.phabricator.com/D21055
This commit is contained in:
parent
62f5bdbbd2
commit
067b04aaf1
1 changed files with 13 additions and 7 deletions
|
@ -417,13 +417,19 @@ abstract class AphrontResponse extends Phobject {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function willBeginWrite() {
|
public function willBeginWrite() {
|
||||||
if ($this->shouldCompressResponse()) {
|
// If we've already sent headers, these "ini_set()" calls will warn that
|
||||||
// Enable automatic compression here. Webservers sometimes do this for
|
// they have no effect. Today, this always happens because we're inside
|
||||||
// us, but we now detect the absence of compression and warn users about
|
// a unit test, so just skip adjusting the setting.
|
||||||
// it so try to cover our bases more thoroughly.
|
|
||||||
ini_set('zlib.output_compression', 1);
|
if (!headers_sent()) {
|
||||||
} else {
|
if ($this->shouldCompressResponse()) {
|
||||||
ini_set('zlib.output_compression', 0);
|
// Enable automatic compression here. Webservers sometimes do this for
|
||||||
|
// us, but we now detect the absence of compression and warn users about
|
||||||
|
// it so try to cover our bases more thoroughly.
|
||||||
|
ini_set('zlib.output_compression', 1);
|
||||||
|
} else {
|
||||||
|
ini_set('zlib.output_compression', 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue