From 4f4fe9b26b9869fa54d42cf460bc3d4db355ab9a Mon Sep 17 00:00:00 2001 From: Zeng1998 Date: Mon, 24 Jun 2024 23:01:19 +0800 Subject: [PATCH] fix: add charset=utf-8 for text content resources (#3608) Co-authored-by: = <=> --- server/router/api/v1/resource_service.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/router/api/v1/resource_service.go b/server/router/api/v1/resource_service.go index 3004cf24..19e6c6f8 100644 --- a/server/router/api/v1/resource_service.go +++ b/server/router/api/v1/resource_service.go @@ -210,8 +210,13 @@ func (s *APIV1Service) GetResourceBinary(ctx context.Context, request *v1pb.GetR } } + contentType := resource.Type + if strings.HasPrefix(contentType, "text/") { + contentType += "; charset=utf-8" + } + httpBody := &httpbody.HttpBody{ - ContentType: resource.Type, + ContentType: contentType, Data: blob, } return httpBody, nil