From 171c6d100e817cea6b869bfe6849c1eaecfccd19 Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Sat, 17 Dec 2016 20:00:53 +0000 Subject: [PATCH] [WebProfilerBundle] Improved cookie traffic --- .../views/Collector/request.html.twig | 36 +++++++++++++------ .../DataCollector/RequestDataCollector.php | 11 ++++++ .../RequestDataCollectorTest.php | 5 ++- 3 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig index cdf2839c6dcd2..4fc6a82c58298 100644 --- a/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig +++ b/src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig @@ -143,16 +143,6 @@ {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestattributes }, with_context = false) }} {% endif %} -

Cookies

- - {% if collector.requestcookies.all is empty %} -
-

No cookies

-
- {% else %} - {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestcookies }, with_context = false) }} - {% endif %} -

Request Headers

{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestheaders, labels: ['Header', 'Value'], maxDepth: 1 }, with_context = false) }} @@ -187,6 +177,32 @@ +
+

Cookies

+ +
+

Request Cookies

+ + {% if collector.requestcookies.all is empty %} +
+

No request cookies

+
+ {% else %} + {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestcookies }, with_context = false) }} + {% endif %} + +

Response Cookies

+ + {% if collector.responsecookies.all is empty %} +
+

No response cookies

+
+ {% else %} + {{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.responsecookies }, with_context = true) }} + {% endif %} +
+
+

Session

diff --git a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php index 9574d5c757a12..270c023d42a60 100644 --- a/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php +++ b/src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php @@ -76,6 +76,11 @@ public function collect(Request $request, Response $response, \Exception $except $statusCode = $response->getStatusCode(); + $responseCookies = array(); + foreach ($response->headers->getCookies() as $cookie) { + $responseCookies[$cookie->getName()] = $cookie; + } + $this->data = array( 'method' => $request->getMethod(), 'format' => $request->getRequestFormat(), @@ -91,6 +96,7 @@ public function collect(Request $request, Response $response, \Exception $except 'request_attributes' => $attributes, 'route' => $route, 'response_headers' => $response->headers->all(), + 'response_cookies' => $responseCookies, 'session_metadata' => $sessionMetadata, 'session_attributes' => $sessionAttributes, 'flashes' => $flashes, @@ -190,6 +196,11 @@ public function getResponseHeaders() return new ParameterBag($this->data['response_headers']->getValue()); } + public function getResponseCookies() + { + return new ParameterBag($this->data['response_cookies']->getValue()); + } + public function getSessionMetadata() { return $this->data['session_metadata']->getValue(); diff --git a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php index 3a95c6b9b64d9..d74f6e00e0543 100644 --- a/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\HttpKernel\Tests\DataCollector; use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Session\Session; use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage; @@ -25,8 +26,6 @@ use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\VarDumper\Cloner\Data; -use Symfony\Component\VarDumper\Cloner\VarCloner; class RequestDataCollectorTest extends TestCase { @@ -36,7 +35,6 @@ public function testCollect() $c->collect($request = $this->createRequest(), $this->createResponse()); - $cloner = new VarCloner(); $attributes = $c->getRequestAttributes(); $this->assertSame('request', $c->getName()); @@ -46,6 +44,7 @@ public function testCollect() $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest()); $this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery()); + $this->assertInstanceOf(ParameterBag::class, $c->getResponseCookies()); $this->assertSame('html', $c->getFormat()); $this->assertEquals('foobar', $c->getRoute()); $this->assertEquals(array('name' => 'foo'), $c->getRouteParams()); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy