mirror of
https://github.com/Ne-Lexa/php-zip.git
synced 2025-07-27 18:50:11 +02:00
Updated ZipFile::outputAsResponse() to conform to PSR standard
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "nelexa/zip",
|
"name": "nelexa/zip",
|
||||||
"description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, ZipAlign tool, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.",
|
|
||||||
"type": "library",
|
"type": "library",
|
||||||
|
"description": "PhpZip is a php-library for extended work with ZIP-archives. Open, create, update, delete, extract and get info tool. Supports appending to existing ZIP files, WinZip AES encryption, Traditional PKWARE Encryption, ZipAlign tool, BZIP2 compression, external file attributes and ZIP64 extensions. Alternative ZipArchive. It does not require php-zip extension.",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"zip",
|
"zip",
|
||||||
"unzip",
|
"unzip",
|
||||||
@@ -11,9 +11,7 @@
|
|||||||
"zipalign",
|
"zipalign",
|
||||||
"ziparchive"
|
"ziparchive"
|
||||||
],
|
],
|
||||||
"require-dev": {
|
"homepage": "https://github.com/Ne-Lexa/php-zip",
|
||||||
"phpunit/phpunit": "4.8"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -22,11 +20,14 @@
|
|||||||
"role": "Developer"
|
"role": "Developer"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"minimum-stability": "stable",
|
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^5.5 || ^7.0",
|
"php": "^5.5 || ^7.0",
|
||||||
"psr/http-message": "^1.0"
|
"psr/http-message": "^1.0"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.8|~5.7",
|
||||||
|
"zendframework/zend-diactoros": "^1.4"
|
||||||
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
"PhpZip\\": "src/PhpZip"
|
"PhpZip\\": "src/PhpZip"
|
||||||
@@ -41,5 +42,6 @@
|
|||||||
"ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt",
|
"ext-openssl": "Needed to support encrypt zip entries or use ext-mcrypt",
|
||||||
"ext-mcrypt": "Needed to support encrypt zip entries or use ext-openssl",
|
"ext-mcrypt": "Needed to support encrypt zip entries or use ext-openssl",
|
||||||
"ext-bz2": "Needed to support BZIP2 compression"
|
"ext-bz2": "Needed to support BZIP2 compression"
|
||||||
}
|
},
|
||||||
|
"minimum-stability": "stable"
|
||||||
}
|
}
|
||||||
|
@@ -1299,11 +1299,11 @@ class ZipFile implements ZipFileInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$stream = new ResponseStream($handle);
|
$stream = new ResponseStream($handle);
|
||||||
$response->withHeader('Content-Type', $mimeType);
|
return $response
|
||||||
$response->withHeader('Content-Disposition', $contentDispositionValue);
|
->withHeader('Content-Type', $mimeType)
|
||||||
$response->withHeader('Content-Length', $stream->getSize());
|
->withHeader('Content-Disposition', $contentDispositionValue)
|
||||||
$response->withBody($stream);
|
->withHeader('Content-Length', $stream->getSize())
|
||||||
return $response;
|
->withBody($stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -7,6 +7,7 @@ use PhpZip\Model\ZipInfo;
|
|||||||
use PhpZip\Util\CryptoUtil;
|
use PhpZip\Util\CryptoUtil;
|
||||||
use PhpZip\Util\FilesUtil;
|
use PhpZip\Util\FilesUtil;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Zend\Diactoros\Response;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ZipFile test
|
* ZipFile test
|
||||||
@@ -1786,9 +1787,10 @@ class ZipFileTest extends ZipTestCase
|
|||||||
$zipFile[$i] = $i;
|
$zipFile[$i] = $i;
|
||||||
}
|
}
|
||||||
$filename = 'file.jar';
|
$filename = 'file.jar';
|
||||||
$response = $this->getMock(ResponseInterface::class);
|
$response = $zipFile->outputAsResponse(new Response(), $filename);
|
||||||
$response = $zipFile->outputAsResponse($response, $filename);
|
|
||||||
$this->assertInstanceOf(ResponseInterface::class, $response);
|
$this->assertInstanceOf(ResponseInterface::class, $response);
|
||||||
|
$this->assertEquals('application/java-archive', $response->getHeaderLine('content-type'));
|
||||||
|
$this->assertEquals('attachment; filename="file.jar"', $response->getHeaderLine('content-disposition'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCompressionLevel()
|
public function testCompressionLevel()
|
||||||
|
Reference in New Issue
Block a user