Skip to content

Commit a05b576

Browse files
committed
fix
1 parent 19aadb7 commit a05b576

4 files changed

Lines changed: 10 additions & 23 deletions

File tree

src/Http/Adapter/Swoole/Request.php

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -391,19 +391,7 @@ protected function generateInput(): array
391391
*/
392392
protected function generateHeaders(): array
393393
{
394-
$headers = $this->swoole->header ?? [];
395-
396-
// Check if cookies are available in a separate property
397-
if (!empty($this->swoole->cookie)) {
398-
// Convert cookies back to Cookie header format
399-
$cookiePairs = [];
400-
foreach ($this->swoole->cookie as $name => $value) {
401-
$cookiePairs[] = $name . '=' . $value;
402-
}
403-
if (!empty($cookiePairs)) {
404-
$headers['cookie'] = implode('; ', $cookiePairs);
405-
}
406-
}
394+
$headers = $this->swoole->header;
407395

408396
foreach ($headers as $key => $value) {
409397
$headers[strtolower($key)] = $value;

src/Http/Adapter/Swoole/Server.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class Server extends Adapter
1818
public function __construct(string $host, ?string $port = null, array $settings = [], int $mode = SWOOLE_PROCESS, ?Container $container = null)
1919
{
2020
$this->server = new SwooleServer($host, (int) $port, $mode);
21-
$this->server->set($settings);
21+
$this->server->set(\array_merge($settings, [
22+
'http_parse_cookie' => false,
23+
]));
2224
$this->container = $container ?? new Container();
2325
}
2426

src/Http/Adapter/SwooleCoroutine/Server.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ class Server extends Adapter
1818
public function __construct(string $host, ?string $port = null, array $settings = [], ?Container $container = null)
1919
{
2020
$this->server = new SwooleServer($host, $port, false, true);
21-
$this->server->set($settings);
21+
$this->server->set(\array_merge($settings, [
22+
'http_parse_cookie' => false,
23+
]));
2224
$this->container = $container ?? new Container();
2325
}
2426

tests/e2e/BaseTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,11 @@ public function testCookie()
5050
$this->assertEquals(200, $response['headers']['status-code']);
5151
$this->assertEquals($cookie, $response['body']);
5252

53-
/**
54-
* Cookie response always expecting space in multiple cookie
55-
* as RFC 6265 (https://datatracker.ietf.org/doc/html/rfc6265#section-4.2.1) recommends it
56-
*/
57-
5853
// Two cookies without optional space
5954
$cookie = 'cookie1=value1;cookie2=value2';
6055
$response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie: ' . $cookie ]);
6156
$this->assertEquals(200, $response['headers']['status-code']);
62-
$this->assertEquals('cookie1=value1; cookie2=value2', $response['body']);
57+
$this->assertEquals($cookie, $response['body']);
6358

6459
// Cookie with "=" in value
6560
$cookie = 'cookie1=value1=value2';
@@ -68,10 +63,10 @@ public function testCookie()
6863
$this->assertEquals($cookie, $response['body']);
6964

7065
// Case sensitivity for cookie names
71-
$cookie = 'cookie1=v1;Cookie1=v2';
66+
$cookie = 'cookie1=v1; Cookie1=v2';
7267
$response = $this->client->call(Client::METHOD_GET, '/cookies', [ 'Cookie: ' . $cookie ]);
7368
$this->assertEquals(200, $response['headers']['status-code']);
74-
$this->assertEquals('cookie1=v1; Cookie1=v2', $response['body']);
69+
$this->assertEquals($cookie, $response['body']);
7570
}
7671

7772
public function testSetCookie()

0 commit comments

Comments
 (0)