namespace wcf\system\request;
+use GuzzleHttp\Psr7\Header;
use Laminas\HttpHandlerRunner\Emitter\SapiEmitter;
use Psr\Http\Message\ResponseInterface;
use wcf\system\application\ApplicationHandler;
}
}
- /**
- * Splits the given array of cache-control values at commas, while properly
- * taking into account that each value might itself contain commas within a
- * quoted string.
- */
- private function splitCacheControl(array $values): \Iterator
- {
- foreach ($values as $value) {
- $isQuoted = false;
- $result = '';
-
- for ($i = 0, $len = \strlen($value); $i < $len; $i++) {
- $char = $value[$i];
- if (!$isQuoted && $char === ',') {
- yield \trim($result);
-
- $isQuoted = false;
- $result = '';
-
- continue;
- }
-
- if ($isQuoted && $char === '\\') {
- $result .= $char;
- $i++;
-
- if ($i < $len) {
- $result .= $value[$i];
-
- continue;
- }
- }
-
- if ($char === '"') {
- $isQuoted = !$isQuoted;
- }
-
- $result .= $char;
- }
-
- if ($result !== '') {
- yield \trim($result);
- }
- }
- }
-
/**
* @since 5.5
*/
$cacheControl = [
'private',
];
- foreach ($this->splitCacheControl($response->getHeader('cache-control')) as $value) {
+ foreach (Header::normalize($response->getHeader('cache-control')) as $value) {
[$field] = \explode('=', $value, 2);
// Prevent duplication of the 'private' field.