Skip to content

Commit a06d300

Browse files
authored
Merge pull request #2127 from brefphp/fix-ci-guzzle-psr7-host-header
Fix CI failure caused by guzzlehttp/psr7 2.12.3 host validation
2 parents 86ae321 + e8b3ca0 commit a06d300

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

tests/Server.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,16 @@ function ($message) {
118118
$message['body'],
119119
$message['version']
120120
);
121-
return $response->withUri(
122-
$response->getUri()
123-
->withScheme('http')
124-
->withHost($response->getHeaderLine('host'))
125-
);
121+
$uri = $response->getUri()->withScheme('http');
122+
$hostHeader = $response->getHeaderLine('host');
123+
if ($hostHeader !== '') {
124+
$parts = explode(':', $hostHeader, 2);
125+
$uri = $uri->withHost($parts[0]);
126+
if (isset($parts[1])) {
127+
$uri = $uri->withPort((int) $parts[1]);
128+
}
129+
}
130+
return $response->withUri($uri);
126131
},
127132
$data
128133
);

0 commit comments

Comments
 (0)