@@ -200,7 +200,7 @@ public function testRestoresResponseContentFromEntityStoreWithLookup()
200200 {
201201 $ this ->storeSimpleEntry ();
202202 $ response = $ this ->store ->lookup ($ this ->request );
203- $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test ' )), $ response ->getContent ( ));
203+ $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test ' )), $ response ->headers -> get ( ' X-Body-File ' ));
204204 }
205205
206206 public function testInvalidatesMetaAndEntityStoreEntriesWithInvalidate ()
@@ -253,9 +253,9 @@ public function testStoresMultipleResponsesForEachVaryCombination()
253253 $ res3 = new Response ('test 3 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
254254 $ this ->store ->write ($ req3 , $ res3 );
255255
256- $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 3 ' )), $ this ->store ->lookup ($ req3 )->getContent ( ));
257- $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 2 ' )), $ this ->store ->lookup ($ req2 )->getContent ( ));
258- $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 1 ' )), $ this ->store ->lookup ($ req1 )->getContent ( ));
256+ $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 3 ' )), $ this ->store ->lookup ($ req3 )->headers -> get ( ' X-Body-File ' ));
257+ $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 2 ' )), $ this ->store ->lookup ($ req2 )->headers -> get ( ' X-Body-File ' ));
258+ $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 1 ' )), $ this ->store ->lookup ($ req1 )->headers -> get ( ' X-Body-File ' ));
259259
260260 $ this ->assertCount (3 , $ this ->getStoreMetadata ($ key ));
261261 }
@@ -265,17 +265,17 @@ public function testOverwritesNonVaryingResponseWithStore()
265265 $ req1 = Request::create ('/test ' , 'get ' , [], [], [], ['HTTP_FOO ' => 'Foo ' , 'HTTP_BAR ' => 'Bar ' ]);
266266 $ res1 = new Response ('test 1 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
267267 $ this ->store ->write ($ req1 , $ res1 );
268- $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 1 ' )), $ this ->store ->lookup ($ req1 )->getContent ( ));
268+ $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 1 ' )), $ this ->store ->lookup ($ req1 )->headers -> get ( ' X-Body-File ' ));
269269
270270 $ req2 = Request::create ('/test ' , 'get ' , [], [], [], ['HTTP_FOO ' => 'Bling ' , 'HTTP_BAR ' => 'Bam ' ]);
271271 $ res2 = new Response ('test 2 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
272272 $ this ->store ->write ($ req2 , $ res2 );
273- $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 2 ' )), $ this ->store ->lookup ($ req2 )->getContent ( ));
273+ $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 2 ' )), $ this ->store ->lookup ($ req2 )->headers -> get ( ' X-Body-File ' ));
274274
275275 $ req3 = Request::create ('/test ' , 'get ' , [], [], [], ['HTTP_FOO ' => 'Foo ' , 'HTTP_BAR ' => 'Bar ' ]);
276276 $ res3 = new Response ('test 3 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
277277 $ key = $ this ->store ->write ($ req3 , $ res3 );
278- $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 3 ' )), $ this ->store ->lookup ($ req3 )->getContent ( ));
278+ $ this ->assertEquals ($ this ->getStorePath ('en ' .hash ('sha256 ' , 'test 3 ' )), $ this ->store ->lookup ($ req3 )->headers -> get ( ' X-Body-File ' ));
279279
280280 $ this ->assertCount (2 , $ this ->getStoreMetadata ($ key ));
281281 }
@@ -330,6 +330,33 @@ public function testDoesNotStorePrivateHeaders()
330330 $ this ->assertNotEmpty ($ response ->headers ->getCookies ());
331331 }
332332
333+ public function testDiscardsInvalidBodyEval ()
334+ {
335+ $ request = Request::create ('https://example.com/foo ' );
336+ $ response = new Response ('foo ' , 200 , ['X-Body-Eval ' => 'SSI ' ]);
337+
338+ $ this ->store ->write ($ request , $ response );
339+ $ this ->assertNull ($ this ->store ->lookup ($ request ));
340+
341+ $ request = Request::create ('https://example.com/foo ' );
342+ $ content = str_repeat ('a ' , 24 ).'b ' .str_repeat ('a ' , 24 ).'b ' ;
343+ $ response = new Response ($ content , 200 , ['X-Body-Eval ' => 'SSI ' ]);
344+
345+ $ this ->store ->write ($ request , $ response );
346+ $ this ->assertNull ($ this ->store ->lookup ($ request ));
347+ }
348+
349+ public function testLoadsBodyEval ()
350+ {
351+ $ request = Request::create ('https://example.com/foo ' );
352+ $ content = str_repeat ('a ' , 24 ).'b ' .str_repeat ('a ' , 24 );
353+ $ response = new Response ($ content , 200 , ['X-Body-Eval ' => 'SSI ' ]);
354+
355+ $ this ->store ->write ($ request , $ response );
356+ $ response = $ this ->store ->lookup ($ request );
357+ $ this ->assertSame ($ content , $ response ->getContent ());
358+ }
359+
333360 protected function storeSimpleEntry ($ path = null , $ headers = [])
334361 {
335362 if (null === $ path ) {
0 commit comments