-
Notifications
You must be signed in to change notification settings - Fork 62
Description
SymfonyResponseTagger::tagSymfonyResponse() uses a comma as the hardcoded glue in order to split n merge tags onto a request:
$this->addTags(explode(',', $response->headers->get($this->getTagsHeaderName())));Unfortunately this collides with the fact that glue is easily configurable CommaSeparatedTagHeaderFormatter and the bundle even automatically changes the glue to space in case varnish xkey is used for purging Configuration:
// Determine the default separator for the tags header, depending on whether we use BAN or xkey
->validate()
->ifTrue(
function ($v) {
return empty($v['tags']['separator']);
}
)
->then(function ($v) {
$v['tags']['separator'] = $this->isVarnishXkey($v) ? ' ' : ',';
return $v;
})Unfortunately I don't think there's a quick solution to this since the TagHeaderFormatter Interface currently doesn't provide any way to determine the glue.
The cleanest solution I can think of would be to expand the TagHeaderFormatter Inteface with a method that splits a header line. This should be fully transparent for consumers and quite trivial to implement since the implementing class should be very much aware how it is configured and how it has to split a tag header it essentially produced.
So I'd propose a counterpart to TagHeaderFormatter::getTagsHeaderValue()
/**
* Get the tag array from an HTTP tag header.
*
* This extracts all tags from a HTTP tag header and ensures correct encoding.
*
* @return string[]
*/
public function getTagsHeaderArray(string $header): array;I'm aware this is a upstream change and would need to be handled there, I'd like to get feedback from a "consumer" first though.