Skip to content

Commit

Permalink
Merge pull request #367 from mikehaertl/366-allow-custom-http-header
Browse files Browse the repository at this point in the history
Issue #366 Allow to pass additional headers to send()
  • Loading branch information
mikehaertl authored Mar 1, 2021
2 parents 4a5cc19 + b75971b commit 17ee713
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
# CHANGELOG

## 2.5.0

* Enhancement: Issue #366 Allow to pass additional HTTP headers to the `send()` method

## 2.4.2

* This release only contains fixes for the test setup.

## 2.4.1

* Fix: Pushed version constraints for php-shellcommand and php-tmpfile which should fix hanging issues.

## 2.4.0

* Enhancement: Issue #307 Improved and unified detection of URL, File, HTML and XML content

## 2.3.1

* Fix: Issue #264 Problem with tmpDir passed in constructor
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
],
"require": {
"php": ">=5.0.0",
"mikehaertl/php-tmpfile": "^1.1.0",
"mikehaertl/php-tmpfile": "^1.2.1",
"mikehaertl/php-shellcommand": "^1.5.0"
},
"autoload": {
Expand Down
11 changes: 9 additions & 2 deletions src/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,21 @@ public function saveAs($filename)
* configured as $type (png, jpg, ...).
* @param bool $inline whether to force inline display of the image, even
* if filename is present.
* @param array $headers a list of additional HTTP headers to send in the
* response as an array. The array keys are the header names like
* 'Cache-Control' and the array values the header value strings to send.
* Each array value can also be another array of strings if the same header
* should be sent multiple times. This can also be used to override
* automatically created headers like 'Expires' or 'Content-Length'. To suppress
* automatically created headers, `false` can also be used as header value.
* @return bool whether image was created successfully
*/
public function send($filename = null,$inline = false)
public function send($filename = null, $inline = false, $headers = array())
{
if (!$this->_isCreated && !$this->createImage()) {
return false;
}
$this->_tmpImageFile->send($filename, $this->getMimeType(), $inline);
$this->_tmpImageFile->send($filename, $this->getMimeType(), $inline, $headers);
return true;
}

Expand Down
11 changes: 9 additions & 2 deletions src/Pdf.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,21 @@ public function saveAs($filename)
* streamed inline.
* @param bool $inline whether to force inline display of the PDF, even if
* filename is present.
* @param array $headers a list of additional HTTP headers to send in the
* response as an array. The array keys are the header names like
* 'Cache-Control' and the array values the header value strings to send.
* Each array value can also be another array of strings if the same header
* should be sent multiple times. This can also be used to override
* automatically created headers like 'Expires' or 'Content-Length'. To suppress
* automatically created headers, `false` can also be used as header value.
* @return bool whether PDF was created successfully
*/
public function send($filename = null,$inline = false)
public function send($filename = null, $inline = false, $headers = array())
{
if (!$this->_isCreated && !$this->createPdf()) {
return false;
}
$this->_tmpPdfFile->send($filename, 'application/pdf', $inline);
$this->_tmpPdfFile->send($filename, 'application/pdf', $inline, $headers);
return true;
}

Expand Down

0 comments on commit 17ee713

Please sign in to comment.