Skip to content

Commit 2ea8e31

Browse files
Merge branch '3.1'
* 3.1: Disable CLI color for Windows 10 greater than 10.0.10586 Exception details break the layout [HttpKernel] Remove wrong docblock [HttpKernel] Fix HttpCache validation HTTP method [FrameworkBundle] Fix default lifetime of cache pools Move space from the before 'if' to the after 'if' [TwigBundle] Add a check for choice's attributes emptiness before calling block('attributes')
2 parents 15fd270 + 1d5845b commit 2ea8e31

File tree

3 files changed

+26
-14
lines changed

3 files changed

+26
-14
lines changed

DataCollector/LoggerDataCollector.php

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,6 @@ public function lateCollect()
6969
}
7070
}
7171

72-
/**
73-
* Gets the called events.
74-
*
75-
* @return array An array of called events
76-
*
77-
* @see TraceableEventDispatcherInterface
78-
*/
79-
public function countErrors()
80-
{
81-
return isset($this->data['error_count']) ? $this->data['error_count'] : 0;
82-
}
83-
8472
/**
8573
* Gets the logs.
8674
*
@@ -96,6 +84,11 @@ public function getPriorities()
9684
return isset($this->data['priorities']) ? $this->data['priorities'] : array();
9785
}
9886

87+
public function countErrors()
88+
{
89+
return isset($this->data['error_count']) ? $this->data['error_count'] : 0;
90+
}
91+
9992
public function countDeprecations()
10093
{
10194
return isset($this->data['deprecation_count']) ? $this->data['deprecation_count'] : 0;

HttpCache/HttpCache.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ protected function validate(Request $request, Response $entry, $catch = false)
354354
$subRequest = clone $request;
355355

356356
// send no head requests because we want content
357-
$subRequest->setMethod('GET');
357+
if ('HEAD' === $request->getMethod()) {
358+
$subRequest->setMethod('GET');
359+
}
358360

359361
// add our cached last-modified validator
360362
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
@@ -415,7 +417,9 @@ protected function fetch(Request $request, $catch = false)
415417
$subRequest = clone $request;
416418

417419
// send no head requests because we want content
418-
$subRequest->setMethod('GET');
420+
if ('HEAD' === $request->getMethod()) {
421+
$subRequest->setMethod('GET');
422+
}
419423

420424
// avoid that the backend sends no content
421425
$subRequest->headers->remove('if_modified_since');

Tests/HttpCache/HttpCacheTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,21 @@ public function testValidatesCachedResponsesWithLastModifiedAndNoFreshnessInform
799799
$this->assertTraceNotContains('miss');
800800
}
801801

802+
public function testValidatesCachedResponsesUseSameHttpMethod()
803+
{
804+
$test = $this;
805+
806+
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) use ($test) {
807+
$test->assertSame('OPTIONS', $request->getMethod());
808+
});
809+
810+
// build initial request
811+
$this->request('OPTIONS', '/');
812+
813+
// build subsequent request
814+
$this->request('OPTIONS', '/');
815+
}
816+
802817
public function testValidatesCachedResponsesWithETagAndNoFreshnessInformation()
803818
{
804819
$this->setNextResponse(200, array(), 'Hello World', function ($request, $response) {

0 commit comments

Comments
 (0)