Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 171c6d1

Browse filesBrowse files
committed
[WebProfilerBundle] Improved cookie traffic
1 parent 5dcef29 commit 171c6d1
Copy full SHA for 171c6d1

File tree

Expand file treeCollapse file tree

3 files changed

+39
-13
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+39
-13
lines changed

‎src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/WebProfilerBundle/Resources/views/Collector/request.html.twig
+26-10Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@
143143
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestattributes }, with_context = false) }}
144144
{% endif %}
145145

146-
<h3>Cookies</h3>
147-
148-
{% if collector.requestcookies.all is empty %}
149-
<div class="empty">
150-
<p>No cookies</p>
151-
</div>
152-
{% else %}
153-
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestcookies }, with_context = false) }}
154-
{% endif %}
155-
156146
<h3>Request Headers</h3>
157147
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestheaders, labels: ['Header', 'Value'], maxDepth: 1 }, with_context = false) }}
158148

@@ -187,6 +177,32 @@
187177
</div>
188178
</div>
189179

180+
<div class="tab {{ collector.requestcookies.all is empty and collector.responsecookies.all is empty ? 'disabled' }}">
181+
<h3 class="tab-title">Cookies</h3>
182+
183+
<div class="tab-content">
184+
<h3>Request Cookies</h3>
185+
186+
{% if collector.requestcookies.all is empty %}
187+
<div class="empty">
188+
<p>No request cookies</p>
189+
</div>
190+
{% else %}
191+
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.requestcookies }, with_context = false) }}
192+
{% endif %}
193+
194+
<h3>Response Cookies</h3>
195+
196+
{% if collector.responsecookies.all is empty %}
197+
<div class="empty">
198+
<p>No response cookies</p>
199+
</div>
200+
{% else %}
201+
{{ include('@WebProfiler/Profiler/bag.html.twig', { bag: collector.responsecookies }, with_context = true) }}
202+
{% endif %}
203+
</div>
204+
</div>
205+
190206
<div class="tab {{ collector.sessionmetadata is empty ? 'disabled' }}">
191207
<h3 class="tab-title">Session</h3>
192208

‎src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/DataCollector/RequestDataCollector.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ public function collect(Request $request, Response $response, \Exception $except
7676

7777
$statusCode = $response->getStatusCode();
7878

79+
$responseCookies = array();
80+
foreach ($response->headers->getCookies() as $cookie) {
81+
$responseCookies[$cookie->getName()] = $cookie;
82+
}
83+
7984
$this->data = array(
8085
'method' => $request->getMethod(),
8186
'format' => $request->getRequestFormat(),
@@ -91,6 +96,7 @@ public function collect(Request $request, Response $response, \Exception $except
9196
'request_attributes' => $attributes,
9297
'route' => $route,
9398
'response_headers' => $response->headers->all(),
99+
'response_cookies' => $responseCookies,
94100
'session_metadata' => $sessionMetadata,
95101
'session_attributes' => $sessionAttributes,
96102
'flashes' => $flashes,
@@ -190,6 +196,11 @@ public function getResponseHeaders()
190196
return new ParameterBag($this->data['response_headers']->getValue());
191197
}
192198

199+
public function getResponseCookies()
200+
{
201+
return new ParameterBag($this->data['response_cookies']->getValue());
202+
}
203+
193204
public function getSessionMetadata()
194205
{
195206
return $this->data['session_metadata']->getValue();

‎src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Tests/DataCollector/RequestDataCollectorTest.php
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\HttpKernel\Tests\DataCollector;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\HttpFoundation\ParameterBag;
1516
use Symfony\Component\HttpFoundation\RedirectResponse;
1617
use Symfony\Component\HttpFoundation\Session\Session;
1718
use Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage;
@@ -25,8 +26,6 @@
2526
use Symfony\Component\HttpFoundation\Response;
2627
use Symfony\Component\HttpFoundation\Cookie;
2728
use Symfony\Component\EventDispatcher\EventDispatcher;
28-
use Symfony\Component\VarDumper\Cloner\Data;
29-
use Symfony\Component\VarDumper\Cloner\VarCloner;
3029

3130
class RequestDataCollectorTest extends TestCase
3231
{
@@ -36,7 +35,6 @@ public function testCollect()
3635

3736
$c->collect($request = $this->createRequest(), $this->createResponse());
3837

39-
$cloner = new VarCloner();
4038
$attributes = $c->getRequestAttributes();
4139

4240
$this->assertSame('request', $c->getName());
@@ -46,6 +44,7 @@ public function testCollect()
4644
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $attributes);
4745
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestRequest());
4846
$this->assertInstanceOf('Symfony\Component\HttpFoundation\ParameterBag', $c->getRequestQuery());
47+
$this->assertInstanceOf(ParameterBag::class, $c->getResponseCookies());
4948
$this->assertSame('html', $c->getFormat());
5049
$this->assertEquals('foobar', $c->getRoute());
5150
$this->assertEquals(array('name' => 'foo'), $c->getRouteParams());

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.