mirror of
https://github.com/ZotPrime/zotprime.git
synced 2021-11-01 23:17:40 +03:00
Disable output compression in PHP
And add compression tests. Compression will be done in Apache instead, which is faster and handles (i.e., skips compression of) 204 responses automatically.
This commit is contained in:
@@ -6,9 +6,6 @@ SetEnvIf X-Forwarded-For "192.168.1.|" !ACCESS_CONTROL
|
||||
order deny,allow
|
||||
deny from env=ACCESS_CONTROL
|
||||
|
||||
php_flag zlib.output_compression On
|
||||
php_value zlib.output_compression_level 5
|
||||
|
||||
php_value include_path "../include"
|
||||
php_value auto_prepend_file "header.inc.php"
|
||||
php_value auto_append_file "footer.inc.php"
|
||||
|
||||
@@ -70,6 +70,21 @@ class APITests extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
|
||||
protected function assertCompression($response) {
|
||||
$this->assertEquals('gzip', $response->getHeader('Content-Encoding'));
|
||||
}
|
||||
|
||||
|
||||
protected function assertNoCompression($response) {
|
||||
$this->assertNull($response->getHeader('Content-Encoding'));
|
||||
}
|
||||
|
||||
|
||||
protected function assertContentLength($length, $response) {
|
||||
$this->assertEquals($length, $response->getHeader('Content-Length'));
|
||||
}
|
||||
|
||||
|
||||
protected function assertISO8601Date($date) {
|
||||
$this->assertTrue(\Zotero_Date::isISO8601($date));
|
||||
}
|
||||
|
||||
@@ -185,4 +185,33 @@ class GeneralTests extends APITests {
|
||||
$this->assertEquals('', $response->getBody());
|
||||
$this->assertEquals('*', $response->getHeader('Access-Control-Allow-Origin'));
|
||||
}
|
||||
|
||||
|
||||
public function test200Compression() {
|
||||
$response = API::get("itemTypes");
|
||||
$this->assertHTTPStatus(200, $response);
|
||||
$this->assertCompression($response);
|
||||
}
|
||||
|
||||
|
||||
public function test404Compression() {
|
||||
$response = API::get("invalidurl");
|
||||
$this->assertHTTPStatus(404, $response);
|
||||
$this->assertCompression($response);
|
||||
}
|
||||
|
||||
|
||||
public function test204NoCompression() {
|
||||
$json = API::createItem("book", [], null, 'jsonData');
|
||||
$response = API::userDelete(
|
||||
self::$config['userID'],
|
||||
"items/{$json['key']}",
|
||||
[
|
||||
"If-Unmodified-Since-Version: {$json['version']}"
|
||||
]
|
||||
);
|
||||
$this->assertHTTPStatus(204, $response);
|
||||
$this->assertNoCompression($response);
|
||||
$this->assertContentLength(0, $response);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user