File tree Expand file tree Collapse file tree 4 files changed +36
-2
lines changed
Expand file tree Collapse file tree 4 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 2424 "scripts" : {
2525 "lint" : " vendor/bin/pint --test" ,
2626 "format" : " vendor/bin/pint" ,
27- "check" : " vendor/bin/phpstan analyse -c phpstan.neon" ,
27+ "check" : " vendor/bin/phpstan analyse -c phpstan.neon --memory-limit 512M " ,
2828 "test" : " vendor/bin/phpunit --configuration phpunit.xml" ,
2929 "bench" : " vendor/bin/phpbench run --report=benchmark"
3030 },
Original file line number Diff line number Diff line change @@ -359,6 +359,21 @@ protected function generateInput(): array
359359 */
360360 protected function generateHeaders (): array
361361 {
362- return $ this ->swoole ->header ;
362+ $ headers = $ this ->swoole ->header ;
363+
364+ if (empty ($ this ->swoole ->cookie )) {
365+ return $ headers ;
366+ }
367+
368+ $ cookieHeaders = [];
369+ foreach ($ this ->swoole ->cookie as $ key => $ value ) {
370+ $ cookieHeaders [] = "{$ key }= {$ value }" ;
371+ }
372+
373+ if (!empty ($ cookieHeaders )) {
374+ $ headers ['cookie ' ] = \implode ('; ' , $ cookieHeaders );
375+ }
376+
377+ return $ headers ;
363378 }
364379}
Original file line number Diff line number Diff line change @@ -35,4 +35,14 @@ public function testFile()
3535 $ response = $ this ->client ->call (Client::METHOD_GET , '/humans.txt ' );
3636 $ this ->assertEquals (204 , $ response ['headers ' ]['status-code ' ]);
3737 }
38+
39+ public function testCookie ()
40+ {
41+ $ response = $ this ->client ->call (Client::METHOD_GET , '/cookies ' , [
42+ 'Cookie: cookie1=value1; cookie2=value2 '
43+ ]);
44+
45+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
46+ $ this ->assertEquals ('cookie1=value1; cookie2=value2 ' , $ response ['body ' ]);
47+ }
3848}
Original file line number Diff line number Diff line change 33require_once __DIR__ .'/../../vendor/autoload.php ' ;
44
55use Utopia \Http \Http ;
6+ use Utopia \Http \Request ;
67use Utopia \Http \Response ;
78use Utopia \Http \Validator \Text ;
89
2526 $ response ->send ($ value );
2627 });
2728
29+
30+ Http::get ('/cookies ' )
31+ ->inject ('request ' )
32+ ->inject ('response ' )
33+ ->action (function (Request $ request , Response $ response ) {
34+ $ response ->send ($ request ->getHeaders ()['cookie ' ] ?? '' );
35+ });
36+
2837Http::get ('/chunked ' )
2938 ->inject ('response ' )
3039 ->action (function (Response $ response ) {
You can’t perform that action at this time.
0 commit comments