From d7877e9ab6a915893fb2552516fcd46b819873a3 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Wed, 14 Dec 2022 13:40:56 +0000 Subject: [PATCH] add Content-Length header for render_json(), fixes #1889 Closes #1889 Merge request studip/studip!1237 --- app/controllers/studip_controller.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/studip_controller.php b/app/controllers/studip_controller.php index 5e9ab358908..253557bc65f 100644 --- a/app/controllers/studip_controller.php +++ b/app/controllers/studip_controller.php @@ -11,6 +11,9 @@ require_once __DIR__ . '/studip_response.php'; +/** + * @property StudipResponse $response + */ abstract class StudipController extends Trails_Controller { protected $with_session = false; //do we need to have a session for this controller @@ -407,8 +410,11 @@ abstract class StudipController extends Trails_Controller */ public function render_json($data) { + $json = json_encode($data); + $this->set_content_type('application/json;charset=utf-8'); - return $this->render_text(json_encode($data)); + $this->response->add_header('Content-Length', strlen($json)); + $this->render_text($json); } /** -- GitLab