@@ -87,12 +87,13 @@ public function needsParsing(Response $response)
8787 return (bool ) preg_match ($ pattern , $ control );
8888 }
8989
90+
9091 /**
9192 * {@inheritdoc}
9293 */
9394 public function handle (HttpCache $ cache , $ uri , $ alt , $ ignoreErrors )
9495 {
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 ());
9697
9798 try {
9899 $ response = $ cache ->handle ($ subRequest , HttpKernelInterface::SUB_REQUEST , true );
@@ -112,4 +113,27 @@ public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors)
112113 }
113114 }
114115 }
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+ }
115139}
0 commit comments