fix: tests

This commit is contained in:
loks0n
2024-11-08 13:01:18 +01:00
parent 83cbddb926
commit ee4b54857f
2 changed files with 12 additions and 10 deletions
+10 -7
View File
@@ -179,9 +179,14 @@ class Client
default => http_build_query($params),
};
foreach ($headers as $i => $header) {
$headers[] = $i . ':' . $header;
unset($headers[$i]);
$formattedHeaders = [];
foreach ($headers as $key => $value) {
if (strtolower($key) === 'accept-encoding') {
curl_setopt($ch, CURLOPT_ENCODING, $value);
continue;
} else {
$formattedHeaders[] = $key . ': ' . $value;
}
}
curl_setopt($ch, CURLOPT_PATH_AS_IS, 1);
@@ -189,7 +194,7 @@ class Client
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_HTTPHEADER, $formattedHeaders);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
curl_setopt($ch, CURLOPT_HEADERFUNCTION, function ($curl, $header) use (&$responseHeaders, &$cookies) {
@@ -221,9 +226,7 @@ class Client
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
}
if (isset($headers['accept-encoding'])) {
curl_setopt($ch, CURLOPT_ENCODING, $headers['accept-encoding']); // Enable automatic decoding
}
curl_setopt($ch, CURLOPT_VERBOSE, true);
$responseBody = curl_exec($ch);
$responseType = $responseHeaders['content-type'] ?? '';
+2 -3
View File
@@ -107,7 +107,7 @@ class CompressionTest extends Scope
'x-appwrite-project' => $this->getProject()['$id'],
], $this->getHeaders()), [
'fileId' => ID::unique(),
'file' => new CURLFile(realpath(__DIR__ . '/../../../resources/logo.png'), 'image/png', 'logo.png'),
'file' => new CURLFile(realpath(__DIR__ . '/../../resources/logo.png'), 'image/png', 'logo.png'),
'permissions' => [
Permission::read(Role::any()),
Permission::update(Role::any()),
@@ -124,8 +124,7 @@ class CompressionTest extends Scope
], $this->getHeaders()));
$this->assertEquals(200, $response['headers']['status-code']);
$this->assertEquals('gzip', $response['headers']['content-encoding']);
$this->assertArrayNotHasKey('content-encoding', $response['headers']);
// get image without
$response = $this->client->call(Client::METHOD_GET, '/storage/buckets/' . $bucketId . '/files/' . $fileId, array_merge([
'content-type' => 'application/json',