Skip to content

Commit 271ce63

Browse files
committed
Add custom Guzzle client section to docs
1 parent e9f97d7 commit 271ce63

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

doc/proxy-clients.rst

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ path::
104104
;
105105

106106
You can specify HTTP headers as the second argument to ``purge()``.
107-
For instance:
107+
For instance::
108108

109109
$client
110110
->purge('/some/path', array('X-Foo' => 'bar')
@@ -114,6 +114,10 @@ For instance:
114114
Please note that purge will invalidate all variants, so you do not have to
115115
send any headers that you vary on, such as ``Accept``.
116116

117+
The above allows you to pass headers that are different between purge requests.
118+
If you want to send headers for all purge requests, such as ``Authorization``,
119+
use a :ref:`custom Guzzle client <custom Guzzle client>` instead.
120+
117121
Refresh
118122
~~~~~~~
119123

@@ -174,3 +178,23 @@ Varnish client::
174178

175179
Make sure to add any headers that you want to ban on to your
176180
:doc:`Varnish configuration <varnish-configuration>`.
181+
182+
.. _custom guzzle client:
183+
184+
Custom Guzzle Client
185+
--------------------
186+
187+
By default, the proxy clients instantiate a `Guzzle client`_ to communicate
188+
with the caching proxy. If you need to customize the requests, for example to
189+
send a basic authentication header, you can inject a custom Guzzle client::
190+
191+
use FOS\HttpCache\ProxyClient\Varnish;
192+
use Guzzle\Http\Client;
193+
194+
$client = new Client();
195+
$client->setDefaultOption('auth', array('username', 'password', 'Digest'));
196+
197+
$servers = array('10.0.0.1');
198+
$varnish = new Varnish($servers, '/baseUrl', $client);
199+
200+
.. _Guzzle client: http://guzzle3.readthedocs.org/

0 commit comments

Comments
 (0)