From 1c8d06cc42dcb04355984d561ce9fbbcf0bb9ef7 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 19 Jul 2017 11:44:21 -0700 Subject: [PATCH] Response content-length header should use mbstring if available. --- VERSION | 2 +- flight/net/Response.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index d5e98f7..785cda8 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.2 \ No newline at end of file +1.3.3 \ No newline at end of file diff --git a/flight/net/Response.php b/flight/net/Response.php index 2b22158..8c72a21 100644 --- a/flight/net/Response.php +++ b/flight/net/Response.php @@ -107,7 +107,7 @@ class Response { * Sets the HTTP status of the response. * * @param int $code HTTP status code. - * @return object Self reference + * @return object|int Self reference * @throws \Exception If invalid status code */ public function status($code = null) { @@ -247,7 +247,11 @@ class Response { } // Send content length - if (($length = strlen($this->body)) > 0) { + $length = (extension_loaded('mbstring')) ? + mb_strlen($this->body, 'latin1') : + strlen($this->body); + + if ($length > 0) { header('Content-Length: '.$length); }