Skip to content

Commit c193338

Browse files
committed
Moved the host:port Host header in Connection:performRequest()
1 parent 422b6ac commit c193338

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Elasticsearch/Connections/Connection.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,11 +168,6 @@ public function __construct(
168168
}
169169
$port = $hostDetails['port'];
170170

171-
if (isset($connectionParams['client']['port_in_header']) && $connectionParams['client']['port_in_header']) {
172-
if (!in_array((int) $port, [80,443])) {
173-
$host .= ":$port";
174-
}
175-
}
176171
$this->host = $host;
177172
$this->path = $path;
178173
$this->port = $port;
@@ -203,6 +198,12 @@ public function performRequest(string $method, string $uri, ?array $params = [],
203198
$this->headers = array_merge($this->headers, $options['client']['headers']);
204199
}
205200

201+
$host = $this->host;
202+
if (isset($this->connectionParams['client']['port_in_header']) && $this->connectionParams['client']['port_in_header']) {
203+
if (!in_array((int) $this->port, [80,443])) {
204+
$host .= ':' . $this->port;
205+
}
206+
}
206207

207208
$request = [
208209
'http_method' => $method,
@@ -211,7 +212,7 @@ public function performRequest(string $method, string $uri, ?array $params = [],
211212
'body' => $body,
212213
'headers' => array_merge(
213214
[
214-
'Host' => [$this->host]
215+
'Host' => [$host]
215216
],
216217
$this->headers
217218
)

0 commit comments

Comments
 (0)