Fixed Request::__toString ignoring cookies
This commit is contained in:
parent
277219d0a7
commit
0f79d09a10
@ -496,9 +496,21 @@ class Request
|
|||||||
return trigger_error($e, E_USER_ERROR);
|
return trigger_error($e, E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$cookieHeader = '';
|
||||||
|
$cookies = array();
|
||||||
|
|
||||||
|
foreach ($this->cookies as $k => $v) {
|
||||||
|
$cookies[] = $k.'='.$v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($cookies)) {
|
||||||
|
$cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
|
||||||
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
|
sprintf('%s %s %s', $this->getMethod(), $this->getRequestUri(), $this->server->get('SERVER_PROTOCOL'))."\r\n".
|
||||||
$this->headers."\r\n".
|
$this->headers.
|
||||||
|
$cookieHeader."\r\n".
|
||||||
$content;
|
$content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1454,8 +1454,18 @@ class RequestTest extends TestCase
|
|||||||
$request = new Request();
|
$request = new Request();
|
||||||
|
|
||||||
$request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
|
$request->headers->set('Accept-language', 'zh, en-us; q=0.8, en; q=0.6');
|
||||||
|
$request->cookies->set('Foo', 'Bar');
|
||||||
|
|
||||||
$this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $request->__toString());
|
$asString = (string) $request;
|
||||||
|
|
||||||
|
$this->assertContains('Accept-Language: zh, en-us; q=0.8, en; q=0.6', $asString);
|
||||||
|
$this->assertContains('Cookie: Foo=Bar', $asString);
|
||||||
|
|
||||||
|
$request->cookies->set('Another', 'Cookie');
|
||||||
|
|
||||||
|
$asString = (string) $request;
|
||||||
|
|
||||||
|
$this->assertContains('Cookie: Foo=Bar; Another=Cookie', $asString);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testIsMethod()
|
public function testIsMethod()
|
||||||
|
Reference in New Issue
Block a user