Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 7d8e6c6

Browse files
committed
Cast int and float to string when creating headers
With the ZF2015-04 patch, we were no longer allowing non-string, non-stringable objects as header values. This broke a number of other classes, however, which required integer and/or float values (e.g., to set a Content-Length header). This patch casts those types to strings before attempting to set them as header values.
1 parent d925ec1 commit 7d8e6c6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/Zend/Http/Client.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,6 +1592,11 @@ protected function _validateHeaderValue($value, $recurse = true)
15921592
return;
15931593
}
15941594

1595+
// Cast integers and floats to strings for purposes of header representation.
1596+
if (is_int($value) || is_float($value)) {
1597+
$value = (string) $value;
1598+
}
1599+
15951600
if (! is_string($value) && (! is_object($value) || ! method_exists($value, '__toString'))) {
15961601
require_once 'Zend/Http/Exception.php';
15971602
throw new Zend_Http_Exception('Invalid header value detected');

0 commit comments

Comments
 (0)