Skip to content
Permalink
Browse files

Better assertions around content-transfer-encoding.

  • Loading branch information...
markstory committed Dec 9, 2016
1 parent 2480c6b commit 966cb034ed8d1a31a6e960ec1ff5b99dfe2735b7
Showing with 4 additions and 7 deletions.
  1. +2 −7 src/Network/Response.php
  2. +2 −0 tests/TestCase/Network/ResponseTest.php
@@ -2149,7 +2149,6 @@ public function file($path, array $options = [])
public function withFile($path, array $options = [])
{
$file = $this->validateFile($path);
$options += [
'name' => null,
'download' => null
@@ -2176,14 +2175,10 @@ public function withFile($path, array $options = [])
$contentType = 'application/force-download';
}
if (!empty($contentType)) {
if (isset($contentType)) {
$new = $new->withType($contentType);
}
if ($options['name'] === null) {
$name = $file->name;
} else {
$name = $options['name'];
}
$name = $options['name'] ?: $file->name;
$new = $new->withDownload($name)
->withHeader('Content-Transfer-Encoding', 'binary');
}
@@ -1680,6 +1680,7 @@ public function testWithFileDownloadAndName()
$new->getHeaderLine('Content-Disposition')
);
$this->assertEquals('bytes', $new->getHeaderLine('Accept-Ranges'));
$this->assertEquals('binary', $new->getHeaderLine('Content-Transfer-Encoding'));
$body = $new->getBody();
$this->assertInstanceOf('Zend\Diactoros\Stream', $body);
@@ -2032,6 +2033,7 @@ public function testWithFileNoDownload()
$new->getHeaderLine('Content-Type')
);
$this->assertFalse($new->hasHeader('Content-Disposition'));
$this->assertFalse($new->hasHeader('Content-Transfer-Encoding'));
}
/**

0 comments on commit 966cb03

Please sign in to comment.
You can’t perform that action at this time.