File tree Expand file tree Collapse file tree 4 files changed +6
-6
lines changed
Expand file tree Collapse file tree 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.
13041304
13051305``` php
13061306$http = new React\Http\HttpServer(function (Psr\Http\Message\ServerRequestInterface $request) {
1307- $key = 'react\php ';
1307+ $key = 'greeting ';
13081308
13091309 if (isset($request->getCookieParams()[$key])) {
13101310 $body = "Your cookie value is: " . $request->getCookieParams()[$key] . "\n";
@@ -1316,7 +1316,7 @@ $http = new React\Http\HttpServer(function (Psr\Http\Message\ServerRequestInterf
13161316
13171317 return React\Http\Message\Response::plaintext(
13181318 "Your cookie has been set.\n"
1319- )->withHeader('Set-Cookie', urlencode( $key) . '=' . urlencode('test;more '));
1319+ )->withHeader('Set-Cookie', $key . '=' . urlencode('Hello world! '));
13201320});
13211321```
13221322
Original file line number Diff line number Diff line change 33require __DIR__ . '/../vendor/autoload.php ' ;
44
55$ http = new React \Http \HttpServer (function (Psr \Http \Message \ServerRequestInterface $ request ) {
6- $ key = 'react\php ' ;
6+ $ key = 'greeting ' ;
77
88 if (isset ($ request ->getCookieParams ()[$ key ])) {
99 $ body = "Your cookie value is: " . $ request ->getCookieParams ()[$ key ] . "\n" ;
1515
1616 return React \Http \Message \Response::plaintext (
1717 "Your cookie has been set. \n"
18- )->withHeader ('Set-Cookie ' , urlencode ( $ key) . '= ' . urlencode ('test;more ' ));
18+ )->withHeader ('Set-Cookie ' , $ key . '= ' . urlencode ('Hello world! ' ));
1919});
2020
2121$ 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)
186186 $ nameValuePair = \explode ('= ' , $ pair , 2 );
187187
188188 if (\count ($ nameValuePair ) === 2 ) {
189- $ key = \urldecode ( $ nameValuePair [0 ]) ;
189+ $ key = $ nameValuePair [0 ];
190190 $ value = \urldecode ($ nameValuePair [1 ]);
191191 $ result [$ key ] = $ value ;
192192 }
Original file line number Diff line number Diff line change @@ -251,7 +251,7 @@ public function testUrlEncodingForKeyWillReturnValidArray()
251251 );
252252
253253 $ cookies = $ this ->request ->getCookieParams ();
254- $ this ->assertEquals (array ('react;php ' => 'is great ' ), $ cookies );
254+ $ this ->assertEquals (array ('react%3Bphp ' => 'is great ' ), $ cookies );
255255 }
256256
257257 public function testCookieWithoutSpaceAfterSeparatorWillBeAccepted ()
You can’t perform that action at this time.
0 commit comments