Skip to content

Commit 5543a80

Browse files
committed
Enable CURLOPT_FORBID_REUSE (fix #97)
The cURL connection re-use caused response headers for different requests to be confused when testing against Varnish 4.0.1 (on PHP 5.5). Varnish 3.0.2 (and possibly 4.0.0) still work fine with re-use.
1 parent c7518e2 commit 5543a80

File tree

2 files changed

+7
-19
lines changed

2 files changed

+7
-19
lines changed

tests/AbstractProxyClientTestCase.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ abstract class AbstractProxyClientTestCase extends \PHPUnit_Framework_TestCase
3232
const CACHE_HIT = 'HIT';
3333

3434
/**
35-
* A guzzle http client.
35+
* A Guzzle HTTP client.
3636
*
3737
* @var Client
3838
*/
@@ -65,6 +65,7 @@ public function assertHit(Response $response, $message = null)
6565
*
6666
* @param string $url
6767
* @param array $headers
68+
* @param array $options
6869
*
6970
* @return Response
7071
*/
@@ -81,7 +82,10 @@ public function getResponse($url, array $headers = array(), $options = array())
8182
public function getClient()
8283
{
8384
if (null === $this->client) {
84-
$this->client = new Client('http://' . $this->getHostName() . ':' . $this->getCachingProxyPort());
85+
$this->client = new Client(
86+
'http://' . $this->getHostName() . ':' . $this->getCachingProxyPort(),
87+
array('curl.options' => array(CURLOPT_FORBID_REUSE => true))
88+
);
8589
}
8690

8791
return $this->client;

tests/Functional/Fixtures/varnish-4/purge.vcl

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,6 @@ sub vcl_recv {
33
if (!client.ip ~ invalidators) {
44
return (synth(405, "Not allowed"));
55
}
6-
return (hash);
7-
}
8-
}
9-
10-
sub vcl_hit {
11-
if (req.method == "PURGE") {
12-
purge;
13-
return (synth(204, "Purged"));
14-
}
15-
}
16-
17-
# The purge in vcl_miss is necessary to purge all variants in the cases where
18-
# you hit an object, but miss a particular variant.
19-
sub vcl_miss {
20-
if (req.method == "PURGE") {
21-
purge;
22-
return (synth(204, "Purged (Not in cache)"));
6+
return (purge);
237
}
248
}

0 commit comments

Comments
 (0)