Skip to content

Commit 9de8878

Browse files
committed
update headers
1 parent e03ba50 commit 9de8878

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

src/Usage/Adapter/ClickHouse.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ public function __construct(
6969
$this->secure = $secure;
7070

7171
$this->client = new Client();
72+
$this->client->addHeader('X-ClickHouse-User', $this->username);
73+
$this->client->addHeader('X-ClickHouse-Key', $this->password);
74+
$this->client->addHeader('X-ClickHouse-Database', $this->database);
7275
}
7376

7477
/**
@@ -160,6 +163,7 @@ public function setDatabase(string $database): self
160163
{
161164
$this->validateIdentifier($database, 'Database');
162165
$this->database = $database;
166+
$this->client->addHeader('X-ClickHouse-Database', $this->database);
163167

164168
return $this;
165169
}
@@ -216,11 +220,6 @@ private function query(string $sql, array $params = []): string
216220
$sql = str_replace(":{$key}", $strValue, $sql);
217221
}
218222

219-
// Set authentication headers
220-
$this->client->addHeader('X-ClickHouse-User', $this->username);
221-
$this->client->addHeader('X-ClickHouse-Key', $this->password);
222-
$this->client->addHeader('X-ClickHouse-Database', $this->database);
223-
224223
try {
225224
$response = $this->client->fetch(
226225
url: $url,

0 commit comments

Comments
 (0)