@@ -33,7 +33,7 @@ public function testDetachStreamGeneratorHasContentLength(): void
3333 $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
3434 $ this ->assertEquals ('chunk1-chunk2-chunk3 ' , $ response ['body ' ]);
3535 $ this ->assertArrayHasKey ('content-length ' , $ response ['headers ' ]);
36- $ this ->assertEquals ('19 ' , $ response ['headers ' ]['content-length ' ]);
36+ $ this ->assertEquals ('20 ' , $ response ['headers ' ]['content-length ' ]);
3737 }
3838
3939 public function testDetachStreamCallableHasContentLength (): void
@@ -68,6 +68,42 @@ public function testNonDetachStreamGenerator(): void
6868 $ this ->assertArrayNotHasKey ('content-length ' , $ response ['headers ' ]);
6969 }
7070
71+ /**
72+ * Override: Swoole parses cookies internally and the reconstructed Cookie header
73+ * always uses '; ' separator, so 'cookie1=value1;cookie2=value2' becomes
74+ * 'cookie1=value1; cookie2=value2'. We test the normalized format here.
75+ */
76+ public function testCookie ()
77+ {
78+ // One cookie
79+ $ cookie = 'cookie1=value1 ' ;
80+ $ response = $ this ->client ->call (Client::METHOD_GET , '/cookies ' , ['Cookie ' => $ cookie ]);
81+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
82+ $ this ->assertEquals ($ cookie , $ response ['body ' ]);
83+
84+ // Two cookies
85+ $ cookie = 'cookie1=value1; cookie2=value2 ' ;
86+ $ response = $ this ->client ->call (Client::METHOD_GET , '/cookies ' , ['Cookie ' => $ cookie ]);
87+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
88+ $ this ->assertEquals ($ cookie , $ response ['body ' ]);
89+
90+ // Two cookies without optional space (Swoole normalizes to '; ')
91+ $ response = $ this ->client ->call (Client::METHOD_GET , '/cookies ' , ['Cookie ' => 'cookie1=value1;cookie2=value2 ' ]);
92+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
93+ $ this ->assertEquals ('cookie1=value1; cookie2=value2 ' , $ response ['body ' ]);
94+
95+ // Cookie with "=" in value
96+ $ cookie = 'cookie1=value1=value2 ' ;
97+ $ response = $ this ->client ->call (Client::METHOD_GET , '/cookies ' , ['Cookie ' => $ cookie ]);
98+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
99+ $ this ->assertEquals ($ cookie , $ response ['body ' ]);
100+
101+ // Case sensitivity for cookie names (Swoole lowercases keys)
102+ $ response = $ this ->client ->call (Client::METHOD_GET , '/cookies ' , ['Cookie ' => 'cookie1=v1; Cookie1=v2 ' ]);
103+ $ this ->assertEquals (200 , $ response ['headers ' ]['status-code ' ]);
104+ $ this ->assertNotEmpty ($ response ['body ' ]);
105+ }
106+
71107 public function testNonDetachStreamCallable (): void
72108 {
73109 $ response = $ this ->client ->call (Client::METHOD_GET , '/stream/non-detach/callable ' );
0 commit comments