1717use FOS \HttpCache \ProxyClient \Invalidation \PurgeInterface ;
1818use FOS \HttpCache \ProxyClient \Invalidation \RefreshInterface ;
1919use FOS \HttpCache \ProxyClient \Invalidation \TagsInterface ;
20- use Http \Client \HttpAsyncClient ;
2120use Http \Message \MessageFactory ;
22- use Symfony \Component \OptionsResolver \OptionsResolver ;
2321
2422/**
2523 * Varnish HTTP cache invalidator.
2624 *
25+ * Additional constructor options:
26+ * - tags_header Header for tagging responses, defaults to X-Cache-Tags
27+ *
2728 * @author David de Boer <david@driebit.nl>
2829 */
2930class Varnish extends AbstractProxyClient implements BanInterface, PurgeInterface, RefreshInterface, TagsInterface
@@ -46,38 +47,6 @@ class Varnish extends AbstractProxyClient implements BanInterface, PurgeInterfac
4647 self ::HTTP_HEADER_CONTENT_TYPE => self ::REGEX_MATCH_ALL
4748 ];
4849
49- /**
50- * Has a base URI been set?
51- *
52- * @var bool
53- */
54- private $ baseUriSet ;
55-
56- /**
57- * @var string
58- */
59- private $ tagsHeader ;
60-
61- /**
62- * {@inheritdoc}
63- *
64- * Additional options:
65- *
66- * - tags_header Header for tagging responses, defaults to X-Cache-Tags
67- *
68- * @param string $tagsHeader
69- */
70- public function __construct (
71- array $ servers ,
72- array $ options = [],
73- HttpAsyncClient $ httpClient = null ,
74- MessageFactory $ messageFactory = null
75- ) {
76- parent ::__construct ($ servers , $ options , $ httpClient , $ messageFactory );
77- $ this ->baseUriSet = $ this ->options ['base_uri ' ] !== null ;
78- $ this ->tagsHeader = $ this ->options ['tags_header ' ];
79- }
80-
8150 /**
8251 * Set the default headers that get merged with the provided headers in self::ban().
8352 *
@@ -107,7 +76,7 @@ public function invalidateTags(array $tags)
10776 {
10877 $ tagExpression = sprintf ('(%s)(,.+)?$ ' , implode ('| ' , array_map ('preg_quote ' , $ this ->escapeTags ($ tags ))));
10978
110- return $ this ->ban ([$ this ->tagsHeader => $ tagExpression ]);
79+ return $ this ->ban ([$ this ->options [ ' tags_header ' ] => $ tagExpression ]);
11180 }
11281
11382 /**
@@ -125,7 +94,7 @@ public function getTagsHeaderValue(array $tags)
12594 */
12695 public function getTagsHeaderName ()
12796 {
128- return $ this ->tagsHeader ;
97+ return $ this ->options [ ' tags_header ' ] ;
12998 }
13099
131100 /**
@@ -215,7 +184,7 @@ protected function queueRequest($method, $url, array $headers = [])
215184 $ request = $ this ->messageFactory ->createRequest ($ method , $ url , $ headers );
216185
217186 if (self ::HTTP_METHOD_BAN !== $ method
218- && ! $ this ->baseUriSet
187+ && null === $ this ->options [ ' base_uri ' ]
219188 && !$ request ->getHeaderLine ('Host ' )
220189 ) {
221190 throw MissingHostException::missingHost ($ url );
0 commit comments