File tree 4 files changed +6
-6
lines changed
4 files changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -1304,7 +1304,7 @@ get all cookies sent with the current request.
1304
1304
1305
1305
``` php
1306
1306
$http = new React\Http\HttpServer(function (Psr\Http\Message\ServerRequestInterface $request) {
1307
- $key = 'react\php ';
1307
+ $key = 'greeting ';
1308
1308
1309
1309
if (isset($request->getCookieParams()[$key])) {
1310
1310
$body = "Your cookie value is: " . $request->getCookieParams()[$key] . "\n";
@@ -1316,7 +1316,7 @@ $http = new React\Http\HttpServer(function (Psr\Http\Message\ServerRequestInterf
1316
1316
1317
1317
return React\Http\Message\Response::plaintext(
1318
1318
"Your cookie has been set.\n"
1319
- )->withHeader('Set-Cookie', urlencode( $key) . '=' . urlencode('test;more '));
1319
+ )->withHeader('Set-Cookie', $key . '=' . urlencode('Hello world! '));
1320
1320
});
1321
1321
```
1322
1322
Original file line number Diff line number Diff line change 3
3
require __DIR__ . '/../vendor/autoload.php ' ;
4
4
5
5
$ http = new React \Http \HttpServer (function (Psr \Http \Message \ServerRequestInterface $ request ) {
6
- $ key = 'react\php ' ;
6
+ $ key = 'greeting ' ;
7
7
8
8
if (isset ($ request ->getCookieParams ()[$ key ])) {
9
9
$ body = "Your cookie value is: " . $ request ->getCookieParams ()[$ key ] . "\n" ;
15
15
16
16
return React \Http \Message \Response::plaintext (
17
17
"Your cookie has been set. \n"
18
- )->withHeader ('Set-Cookie ' , urlencode ( $ key) . '= ' . urlencode ('test;more ' ));
18
+ )->withHeader ('Set-Cookie ' , $ key . '= ' . urlencode ('Hello world! ' ));
19
19
});
20
20
21
21
$ socket = new React \Socket \SocketServer (isset ($ argv [1 ]) ? $ argv [1 ] : '0.0.0.0:0 ' );
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ private function parseCookie($cookie)
186
186
$ nameValuePair = \explode ('= ' , $ pair , 2 );
187
187
188
188
if (\count ($ nameValuePair ) === 2 ) {
189
- $ key = \urldecode ( $ nameValuePair [0 ]) ;
189
+ $ key = $ nameValuePair [0 ];
190
190
$ value = \urldecode ($ nameValuePair [1 ]);
191
191
$ result [$ key ] = $ value ;
192
192
}
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ public function testUrlEncodingForKeyWillReturnValidArray()
251
251
);
252
252
253
253
$ cookies = $ this ->request ->getCookieParams ();
254
- $ this ->assertEquals (array ('react;php ' => 'is great ' ), $ cookies );
254
+ $ this ->assertEquals (array ('react%3Bphp ' => 'is great ' ), $ cookies );
255
255
}
256
256
257
257
public function testCookieWithoutSpaceAfterSeparatorWillBeAccepted ()
You can’t perform that action at this time.
0 commit comments