From 96e71e48468bbb118ec3f7f9ea6e1bb6a1d16b8d Mon Sep 17 00:00:00 2001 From: tablecell Date: Sat, 25 Sep 2021 20:42:33 +0800 Subject: [PATCH] Update watts.rb add custom response.header ['Content-Type'] like 'application/json' ```RUBY post { response.header['Content-Type']= 'application/json' request.params.to_hash.to_json } ``` --- lib/watts.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/watts.rb b/lib/watts.rb index 13bfa2b..ffcdb15 100644 --- a/lib/watts.rb +++ b/lib/watts.rb @@ -236,6 +236,8 @@ def self.inherited base end # TODO: Problems. + content_type=response.header['Content-Type'] || 'text/html;charset=utf8' + case resp when nil response @@ -245,7 +247,7 @@ def self.inherited base resp = resp.to_s [ 200, - {'Content-Type' => 'text/plain', + {'Content-Type' => >content_type #'text/plain', 'Content-Length' => resp.bytesize.to_s, }, [resp]