Skip to content

Commit bc23b72

Browse files
committed
Merge branch '2.4' into 2.5
* 2.4: PHP Fatal error when getContainer method of ContainerAwareCommand has be... [HttpFoundation] Fixed isSecure() check to be compliant with the docs Update MimeTypeExtensionGuesser.php fix test src/Symfony/Component/HttpFoundation/Tests/BinaryFileResponseTest.php Fixed the Travis build on PHP 5.3.3
2 parents ac7e28c + 4dbd3a1 commit bc23b72

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

File/MimeType/MimeTypeExtensionGuesser.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -723,6 +723,7 @@ class MimeTypeExtensionGuesser implements ExtensionGuesserInterface
723723
'text/plain' => 'txt',
724724
'text/prs.lines.tag' => 'dsc',
725725
'text/richtext' => 'rtx',
726+
'text/rtf' => 'rtf',
726727
'text/sgml' => 'sgml',
727728
'text/tab-separated-values' => 'tsv',
728729
'text/troff' => 't',

Request.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1123,7 +1123,9 @@ public function isSecure()
11231123
return in_array(strtolower(current(explode(',', $proto))), array('https', 'on', 'ssl', '1'));
11241124
}
11251125

1126-
return 'on' == strtolower($this->server->get('HTTPS')) || 1 == $this->server->get('HTTPS');
1126+
$https = $this->server->get('HTTPS');
1127+
1128+
return !empty($https) && 'off' !== strtolower($https);
11271129
}
11281130

11291131
/**

Tests/BinaryFileResponseTest.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@ class BinaryFileResponseTest extends ResponseTestCase
1919
{
2020
public function testConstruction()
2121
{
22-
$response = new BinaryFileResponse('README.md', 404, array('X-Header' => 'Foo'), true, null, true, true);
22+
$file = __DIR__ . '/../README.md';
23+
$response = new BinaryFileResponse($file, 404, array('X-Header' => 'Foo'), true, null, true, true);
2324
$this->assertEquals(404, $response->getStatusCode());
2425
$this->assertEquals('Foo', $response->headers->get('X-Header'));
2526
$this->assertTrue($response->headers->has('ETag'));
2627
$this->assertTrue($response->headers->has('Last-Modified'));
2728
$this->assertFalse($response->headers->has('Content-Disposition'));
2829

29-
$response = BinaryFileResponse::create('README.md', 404, array(), true, ResponseHeaderBag::DISPOSITION_INLINE);
30+
$response = BinaryFileResponse::create($file, 404, array(), true, ResponseHeaderBag::DISPOSITION_INLINE);
3031
$this->assertEquals(404, $response->getStatusCode());
3132
$this->assertFalse($response->headers->has('ETag'));
3233
$this->assertEquals('inline; filename="README.md"', $response->headers->get('Content-Disposition'));
@@ -37,13 +38,13 @@ public function testConstruction()
3738
*/
3839
public function testSetContent()
3940
{
40-
$response = new BinaryFileResponse('README.md');
41+
$response = new BinaryFileResponse(__FILE__);
4142
$response->setContent('foo');
4243
}
4344

4445
public function testGetContent()
4546
{
46-
$response = new BinaryFileResponse('README.md');
47+
$response = new BinaryFileResponse(__FILE__);
4748
$this->assertFalse($response->getContent());
4849
}
4950

@@ -160,7 +161,7 @@ public function testXSendfile()
160161
$request->headers->set('X-Sendfile-Type', 'X-Sendfile');
161162

162163
BinaryFileResponse::trustXSendfileTypeHeader();
163-
$response = BinaryFileResponse::create('README.md');
164+
$response = BinaryFileResponse::create(__DIR__ . '/../README.md');
164165
$response->prepare($request);
165166

166167
$this->expectOutputString('');
@@ -187,9 +188,12 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
187188
$file->expects($this->any())
188189
->method('isReadable')
189190
->will($this->returnValue(true));
191+
$file->expects($this->any())
192+
->method('getMTime')
193+
->will($this->returnValue(time()));
190194

191195
BinaryFileResponse::trustXSendFileTypeHeader();
192-
$response = new BinaryFileResponse('README.md');
196+
$response = new BinaryFileResponse($file);
193197
$reflection = new \ReflectionObject($response);
194198
$property = $reflection->getProperty('file');
195199
$property->setAccessible(true);
@@ -209,6 +213,6 @@ public function getSampleXAccelMappings()
209213

210214
protected function provideResponse()
211215
{
212-
return new BinaryFileResponse('README.md');
216+
return new BinaryFileResponse(__DIR__ . '/../README.md');
213217
}
214218
}

0 commit comments

Comments
 (0)