Skip to content

Commit 0fc037c

Browse files
committed
Fix Host header for proxy client requests
When using `ban` requests with Varnish proxy client, requests are queued and sent with `flush()`. Queued requests are registered without host, making Guzzle create an empty `Host` header. When flushing, Guzzle request is re-created starting with the original one (so without host), with all registered headers. The problem is that the empty `Host` header is also copied, and thus not re-created by Guzzle with the server URL. In the backend, cURL sees it and takes it into account, overriding passed URL silently. This causes requests with empty host being fired by Guzzle, which is kind of annoying 😃.
1 parent 1e0a515 commit 0fc037c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ProxyClient/AbstractProxyClient.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,14 @@ private function sendRequests(array $requests)
161161
$allRequests = array();
162162

163163
foreach ($requests as $request) {
164+
$headers = $request->getHeaders();
165+
// Force to re-create Host header for each proxy request
166+
unset($headers['Host']);
164167
foreach ($this->servers as $server) {
165168
$proxyRequest = $this->client->createRequest(
166169
$request->getMethod(),
167170
$server . $request->getResource(),
168-
$request->getHeaders()
171+
$headers
169172
);
170173
$allRequests[] = $proxyRequest;
171174
}

0 commit comments

Comments
 (0)