Example #1
0
 /**
  * {@inheritDoc}
  *
  * When creating the client, you can configure options:
  *
  * - purge_method:         HTTP method that identifies purge requests.
  *
  * @param array $options The purge_method that should be used.
  */
 public function __construct(array $servers, $baseUrl = null, HttpAdapter $httpAdapter = null, $options = [])
 {
     parent::__construct($servers, $baseUrl, $httpAdapter);
     $resolver = new OptionsResolver();
     $resolver->setDefaults(['purge_method' => PurgeSubscriber::DEFAULT_PURGE_METHOD]);
     $this->options = $resolver->resolve($options);
 }
Example #2
0
 /**
  * {@inheritDoc}
  *
  * When creating the client, you can configure options:
  *
  * - purge_method:         HTTP method that identifies purge requests.
  *
  * @param array $options The purge_method that should be used.
  */
 public function __construct(array $servers, $baseUrl = null, ClientInterface $client = null, array $options = array())
 {
     parent::__construct($servers, $baseUrl, $client);
     $resolver = new OptionsResolver();
     $resolver->setDefaults(array('purge_method' => PurgeSubscriber::DEFAULT_PURGE_METHOD));
     $this->options = $resolver->resolve($options);
 }
Example #3
0
File: Nginx.php Project: ataxel/tp
 /**
  * {@inheritdoc}
  *
  * @param array           $servers       Caching proxy server hostnames or IP addresses,
  *                                       including port if not port 80.
  *                                       E.g. array('127.0.0.1:6081')
  * @param string          $baseUrl       Default application hostname, optionally
  *                                       including base URL, for purge and refresh
  *                                       requests (optional). This is required if
  *                                       you purge and refresh paths instead of
  *                                       absolute URLs.
  * @param string          $purgeLocation Path that triggers purge (optional).
  * @param ClientInterface $client        HTTP client (optional). If no HTTP client
  *                                       is supplied, a default one will be
  *                                       created.
  */
 public function __construct(
     array $servers,
     $baseUrl = null,
     $purgeLocation = '',
     ClientInterface $client = null
 ) {
     $this->purgeLocation = (string) $purgeLocation;
     parent::__construct($servers, $baseUrl, $client);
 }
Example #4
0
    /**
     * {@inheritdoc}
     *
     * @throws MissingHostException If a relative path is queued for purge/
     *                              refresh and no base URL is set
     *
     */
    protected function createRequest($method, $url, array $headers = array())
    {
        $request = parent::createRequest($method, $url, $headers);

        // For purge and refresh, add a host header to the request if it hasn't
        // been set
        if (self::HTTP_METHOD_BAN !== $method
            && '' == $request->getHeader('Host')
        ) {
            throw MissingHostException::missingHost($url);
        }

        return $request;
    }
Example #5
0
 /**
  * {@inheritdoc}
  *
  * @throws MissingHostException If a relative path is queued for purge/
  *                              refresh and no base URL is set
  *
  */
 protected function queueRequest($method, $url, array $headers = [])
 {
     $request = new InvalidationRequest($method, $url, $headers);
     if (self::HTTP_METHOD_BAN !== $method && !$this->baseUriSet && !$request->getHeaderLine('Host')) {
         throw MissingHostException::missingHost($url);
     }
     parent::queueRequest($method, $url, $headers);
 }
Example #6
0
 protected function getDefaultOptions()
 {
     $resolver = parent::getDefaultOptions();
     $resolver->setDefaults(['purge_method' => PurgeSubscriber::DEFAULT_PURGE_METHOD]);
     return $resolver;
 }
Example #7
0
 /**
  * {@inheritdoc}
  */
 protected function getDefaultOptions()
 {
     $resolver = parent::getDefaultOptions();
     $resolver->setDefaults(['tags_header' => 'X-Cache-Tags']);
     $resolver->setDefaults(['header_length' => 7500]);
     return $resolver;
 }