Skip to content

Commit b46c3e6

Browse files
Merge branch '2.7' into 2.8
* 2.7: 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 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 74bfa8b + 5fbcf75 commit b46c3e6

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
@@ -68,18 +68,6 @@ public function lateCollect()
6868
}
6969
}
7070

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

86+
public function countErrors()
87+
{
88+
return isset($this->data['error_count']) ? $this->data['error_count'] : 0;
89+
}
90+
9891
public function countDeprecations()
9992
{
10093
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
@@ -374,7 +374,9 @@ protected function validate(Request $request, Response $entry, $catch = false)
374374
$subRequest = clone $request;
375375

376376
// send no head requests because we want content
377-
$subRequest->setMethod('GET');
377+
if ('HEAD' === $request->getMethod()) {
378+
$subRequest->setMethod('GET');
379+
}
378380

379381
// add our cached last-modified validator
380382
$subRequest->headers->set('if_modified_since', $entry->headers->get('Last-Modified'));
@@ -435,7 +437,9 @@ protected function fetch(Request $request, $catch = false)
435437
$subRequest = clone $request;
436438

437439
// send no head requests because we want content
438-
$subRequest->setMethod('GET');
440+
if ('HEAD' === $request->getMethod()) {
441+
$subRequest->setMethod('GET');
442+
}
439443

440444
// avoid that the backend sends no content
441445
$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)