From 41fe5210841ae89a78becdad5bffb34ed17951dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B2=88=E5=94=81?= <52o@qq52o.cn> Date: Mon, 6 Mar 2023 17:30:11 +0800 Subject: [PATCH] Fix duplicate content-type definition (#5481) --- src/http-server/src/CoreMiddleware.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/http-server/src/CoreMiddleware.php b/src/http-server/src/CoreMiddleware.php index 4202f49a0..3f3335f72 100644 --- a/src/http-server/src/CoreMiddleware.php +++ b/src/http-server/src/CoreMiddleware.php @@ -200,7 +200,11 @@ class CoreMiddleware implements CoreMiddlewareInterface ->withBody(new SwooleStream((string) $response)); } - return $this->response()->withAddedHeader('content-type', 'text/plain')->withBody(new SwooleStream((string) $response)); + if ($this->response()->hasHeader('content-type')) { + return $this->response()->withBody(new SwooleStream((string) $response)); + } + + return $this->response()->withHeader('content-type', 'text/plain')->withBody(new SwooleStream((string) $response)); } /**