Skip to content
Browse files

move setting the Host header in sendRequestToAllVarnishes

  • Loading branch information...
1 parent 41d7291 commit 60fba63ec437d9771f43d01072f610feefd618e5 Gunther Konig committed
Showing with 10 additions and 7 deletions.
  1. +10 −7 Helper/Varnish.php
View
17 Helper/Varnish.php
@@ -74,12 +74,6 @@ public function __construct($domain, array $ips, $port)
*/
public function invalidatePath($path, array $options = array())
{
- $headers = array(
- sprintf('Host: %s', $this->domain)
- );
-
- $options[CURLOPT_HTTPHEADER] = $headers;
-
//Garanteed to be a purge request
$options[CURLOPT_CUSTOMREQUEST] = 'PURGE';
@@ -126,10 +120,19 @@ protected function sendRequestToAllVarnishes($request, array $options = array())
$curlHandler = curl_init($this->domain);
- foreach ($options as $option => $value) {
+ $headers = array(
+ sprintf('Host: %s', $this->domain)
+ );
+ if (isset($options[CURLOPT_HTTPHEADER])) {
+ $options[CURLOPT_HTTPHEADER] = array_merge($headers, $options[CURLOPT_HTTPHEADER]);
+ } else {
+ $options[CURLOPT_HTTPHEADER] = $headers;
+ }
+ foreach ($options as $option => $value) {
curl_setopt($curlHandler, (int) $option, $value);
}
+
//Default Options
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandler, CURLOPT_HEADER, true); // Display headers

0 comments on commit 60fba63

Please sign in to comment.
Something went wrong with that request. Please try again.