@@ -87,12 +87,13 @@ public function needsParsing(Response $response)
87
87
return (bool ) preg_match ($ pattern , $ control );
88
88
}
89
89
90
+
90
91
/**
91
92
* {@inheritdoc}
92
93
*/
93
94
public function handle (HttpCache $ cache , $ uri , $ alt , $ ignoreErrors )
94
95
{
95
- $ subRequest = Request::create ($ uri , ' get ' , array (), $ cache ->getRequest ()->cookies ->all (), array (), $ cache ->getRequest ()->server ->all ());
96
+ $ subRequest = Request::create ($ uri , Request:: METHOD_GET , array (), $ cache ->getRequest ()->cookies ->all (), array (), $ cache ->getRequest ()->server ->all ());
96
97
97
98
try {
98
99
$ response = $ cache ->handle ($ subRequest , HttpKernelInterface::SUB_REQUEST , true );
@@ -112,4 +113,27 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors)
112
113
}
113
114
}
114
115
}
116
+
117
+ /**
118
+ * Remove the Surrogate from the Surrogate-Control header.
119
+ *
120
+ * @param Response $response
121
+ */
122
+ protected function removeFromControl (Response $ response )
123
+ {
124
+ if (!$ response ->headers ->has ('Surrogate-Control ' )) {
125
+ return ;
126
+ }
127
+
128
+ $ value = $ response ->headers ->get ('Surrogate-Control ' );
129
+ $ upperName = strtoupper ($ this ->getName ());
130
+
131
+ if (sprintf ('content="%s/1.0" ' , $ upperName ) == $ value ) {
132
+ $ response ->headers ->remove ('Surrogate-Control ' );
133
+ } elseif (preg_match (sprintf ('#,\s*content="%s/1.0"# ' , $ upperName ), $ value )) {
134
+ $ response ->headers ->set ('Surrogate-Control ' , preg_replace (sprintf ('#,\s*content="%s/1.0"# ' , $ upperName ), '' , $ value ));
135
+ } elseif (preg_match (sprintf ('#content="%s/1.0",\s*# ' , $ upperName ), $ value )) {
136
+ $ response ->headers ->set ('Surrogate-Control ' , preg_replace (sprintf ('#content="%s/1.0",\s*# ' , $ upperName ), '' , $ value ));
137
+ }
138
+ }
115
139
}
0 commit comments