@@ -200,7 +200,7 @@ public function testRestoresResponseContentFromEntityStoreWithLookup()
200
200
{
201
201
$ this ->storeSimpleEntry ();
202
202
$ 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 ' ));
204
204
}
205
205
206
206
public function testInvalidatesMetaAndEntityStoreEntriesWithInvalidate ()
@@ -253,9 +253,9 @@ public function testStoresMultipleResponsesForEachVaryCombination()
253
253
$ res3 = new Response ('test 3 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
254
254
$ this ->store ->write ($ req3 , $ res3 );
255
255
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 ' ));
259
259
260
260
$ this ->assertCount (3 , $ this ->getStoreMetadata ($ key ));
261
261
}
@@ -265,17 +265,17 @@ public function testOverwritesNonVaryingResponseWithStore()
265
265
$ req1 = Request::create ('/test ' , 'get ' , [], [], [], ['HTTP_FOO ' => 'Foo ' , 'HTTP_BAR ' => 'Bar ' ]);
266
266
$ res1 = new Response ('test 1 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
267
267
$ 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 ' ));
269
269
270
270
$ req2 = Request::create ('/test ' , 'get ' , [], [], [], ['HTTP_FOO ' => 'Bling ' , 'HTTP_BAR ' => 'Bam ' ]);
271
271
$ res2 = new Response ('test 2 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
272
272
$ 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 ' ));
274
274
275
275
$ req3 = Request::create ('/test ' , 'get ' , [], [], [], ['HTTP_FOO ' => 'Foo ' , 'HTTP_BAR ' => 'Bar ' ]);
276
276
$ res3 = new Response ('test 3 ' , 200 , ['Vary ' => 'Foo Bar ' ]);
277
277
$ 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 ' ));
279
279
280
280
$ this ->assertCount (2 , $ this ->getStoreMetadata ($ key ));
281
281
}
@@ -330,6 +330,33 @@ public function testDoesNotStorePrivateHeaders()
330
330
$ this ->assertNotEmpty ($ response ->headers ->getCookies ());
331
331
}
332
332
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
+
333
360
protected function storeSimpleEntry ($ path = null , $ headers = [])
334
361
{
335
362
if (null === $ path ) {
0 commit comments