1 | <?php |
||
27 | abstract class AbstractProxyClient implements ProxyClientInterface |
||
28 | { |
||
29 | /** |
||
30 | * HTTP client adapter. |
||
31 | * |
||
32 | * @var HttpAdapter |
||
33 | */ |
||
34 | protected $httpAdapter; |
||
35 | |||
36 | /** |
||
37 | * @var MessageFactory |
||
38 | */ |
||
39 | protected $messageFactory; |
||
40 | |||
41 | /** |
||
42 | * The options configured in the constructor argument or default values. |
||
43 | * |
||
44 | * @var array The resolved options. |
||
45 | */ |
||
46 | protected $options; |
||
47 | |||
48 | /** |
||
49 | * Constructor |
||
50 | * |
||
51 | * Supported options: |
||
52 | * |
||
53 | * - base_uri Default application hostname, optionally including base URL, |
||
54 | * for purge and refresh requests (optional). This is required if you |
||
55 | * purge and refresh paths instead of absolute URLs. |
||
56 | * |
||
57 | * @param array $servers Caching proxy server hostnames or IP |
||
58 | * addresses, including port if not port 80. |
||
59 | * E.g. ['127.0.0.1:6081'] |
||
60 | * @param array $options List of options for the client. |
||
61 | * @param HttpAsyncClient|null $httpClient Client capable of sending HTTP requests. If no |
||
62 | * client is supplied, a default one is created. |
||
63 | * @param MessageFactory|null $messageFactory Factory for PSR-7 messages. If none supplied, |
||
64 | * a default one is created. |
||
65 | */ |
||
66 | 45 | public function __construct( |
|
79 | |||
80 | /** |
||
81 | * {@inheritdoc} |
||
82 | */ |
||
83 | 38 | public function flush() |
|
87 | |||
88 | /** |
||
89 | * Get options resolver with default settings. |
||
90 | * |
||
91 | * @return OptionsResolver |
||
92 | */ |
||
93 | 45 | protected function getDefaultOptions() |
|
100 | |||
101 | /** |
||
102 | * Create a request and queue it with the HttpAdapter. |
||
103 | * |
||
104 | * @param string $method |
||
105 | * @param string|UriInterface $url |
||
106 | * @param array $headers |
||
107 | */ |
||
108 | 13 | protected function queueRequest($method, $url, array $headers) |
|
114 | |||
115 | /** |
||
116 | * Make sure that the tags are valid. |
||
117 | * |
||
118 | * Reusable function for proxy clients. |
||
119 | * Escapes `,` and `\n` (newline) characters. |
||
120 | * |
||
121 | * @param array $tags The tags to escape. |
||
122 | * |
||
123 | * @return array Sane tags. |
||
124 | */ |
||
125 | protected function escapeTags(array $tags) |
||
133 | } |
||
134 |