Skip to content

Commit

Permalink
move setting the Host header in sendRequestToAllVarnishes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunther Konig committed Mar 27, 2013
1 parent 41d7291 commit 60fba63
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Helper/Varnish.php
Expand Up @@ -74,12 +74,6 @@ public function __construct($domain, array $ips, $port)
*/ */
public function invalidatePath($path, array $options = array()) public function invalidatePath($path, array $options = array())
{ {
$headers = array(
sprintf('Host: %s', $this->domain)
);

$options[CURLOPT_HTTPHEADER] = $headers;

//Garanteed to be a purge request //Garanteed to be a purge request
$options[CURLOPT_CUSTOMREQUEST] = 'PURGE'; $options[CURLOPT_CUSTOMREQUEST] = 'PURGE';


Expand Down Expand Up @@ -126,10 +120,19 @@ protected function sendRequestToAllVarnishes($request, array $options = array())


$curlHandler = curl_init($this->domain); $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); curl_setopt($curlHandler, (int) $option, $value);
} }

//Default Options //Default Options
curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlHandler, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curlHandler, CURLOPT_HEADER, true); // Display headers curl_setopt($curlHandler, CURLOPT_HEADER, true); // Display headers
Expand Down

0 comments on commit 60fba63

Please sign in to comment.