Skip to content

Commit 17ee713

Browse files
authored
Merge pull request #367 from mikehaertl/366-allow-custom-http-header
Issue #366 Allow to pass additional headers to send()
2 parents 4a5cc19 + b75971b commit 17ee713

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# CHANGELOG
22

3+
## 2.5.0
4+
5+
* Enhancement: Issue #366 Allow to pass additional HTTP headers to the `send()` method
6+
7+
## 2.4.2
8+
9+
* This release only contains fixes for the test setup.
10+
11+
## 2.4.1
12+
13+
* Fix: Pushed version constraints for php-shellcommand and php-tmpfile which should fix hanging issues.
14+
15+
## 2.4.0
16+
17+
* Enhancement: Issue #307 Improved and unified detection of URL, File, HTML and XML content
18+
319
## 2.3.1
420

521
* Fix: Issue #264 Problem with tmpDir passed in constructor

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"require": {
1515
"php": ">=5.0.0",
16-
"mikehaertl/php-tmpfile": "^1.1.0",
16+
"mikehaertl/php-tmpfile": "^1.2.1",
1717
"mikehaertl/php-shellcommand": "^1.5.0"
1818
},
1919
"autoload": {

src/Image.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,21 @@ public function saveAs($filename)
133133
* configured as $type (png, jpg, ...).
134134
* @param bool $inline whether to force inline display of the image, even
135135
* if filename is present.
136+
* @param array $headers a list of additional HTTP headers to send in the
137+
* response as an array. The array keys are the header names like
138+
* 'Cache-Control' and the array values the header value strings to send.
139+
* Each array value can also be another array of strings if the same header
140+
* should be sent multiple times. This can also be used to override
141+
* automatically created headers like 'Expires' or 'Content-Length'. To suppress
142+
* automatically created headers, `false` can also be used as header value.
136143
* @return bool whether image was created successfully
137144
*/
138-
public function send($filename = null,$inline = false)
145+
public function send($filename = null, $inline = false, $headers = array())
139146
{
140147
if (!$this->_isCreated && !$this->createImage()) {
141148
return false;
142149
}
143-
$this->_tmpImageFile->send($filename, $this->getMimeType(), $inline);
150+
$this->_tmpImageFile->send($filename, $this->getMimeType(), $inline, $headers);
144151
return true;
145152
}
146153

src/Pdf.php

+9-2
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,21 @@ public function saveAs($filename)
189189
* streamed inline.
190190
* @param bool $inline whether to force inline display of the PDF, even if
191191
* filename is present.
192+
* @param array $headers a list of additional HTTP headers to send in the
193+
* response as an array. The array keys are the header names like
194+
* 'Cache-Control' and the array values the header value strings to send.
195+
* Each array value can also be another array of strings if the same header
196+
* should be sent multiple times. This can also be used to override
197+
* automatically created headers like 'Expires' or 'Content-Length'. To suppress
198+
* automatically created headers, `false` can also be used as header value.
192199
* @return bool whether PDF was created successfully
193200
*/
194-
public function send($filename = null,$inline = false)
201+
public function send($filename = null, $inline = false, $headers = array())
195202
{
196203
if (!$this->_isCreated && !$this->createPdf()) {
197204
return false;
198205
}
199-
$this->_tmpPdfFile->send($filename, 'application/pdf', $inline);
206+
$this->_tmpPdfFile->send($filename, 'application/pdf', $inline, $headers);
200207
return true;
201208
}
202209

0 commit comments

Comments
 (0)