diff --git a/spec/context_spec.cr b/spec/context_spec.cr index 29216c6..a144c79 100644 --- a/spec/context_spec.cr +++ b/spec/context_spec.cr @@ -80,18 +80,6 @@ describe "Context" do ("UTF-8".in? client_response.headers["Content-Type"]).should be_true end - it "encodes json in utf-8" do - http_handler = Grip::Routers::Http.new - http_handler.add_route "GET", "/", ExampleController.new, [:none], ->(context : HTTP::Server::Context) do - context.json({:message => "👋🏼 grip"}).halt - end - - request = HTTP::Request.new("GET", "/") - client_response = call_request_on_app(request, http_handler) - client_response.body.should eq "{\"message\":\"👋🏼 grip\"}" - ("UTF-8".in? client_response.headers["Content-Type"]).should be_true - end - it "encodes html in utf-8" do http_handler = Grip::Routers::Http.new http_handler.add_route "GET", "/", ExampleController.new, [:none], ->(context : HTTP::Server::Context) do diff --git a/src/grip/extensions/context.cr b/src/grip/extensions/context.cr index 1b6d9b7..cc52bb1 100644 --- a/src/grip/extensions/context.cr +++ b/src/grip/extensions/context.cr @@ -92,7 +92,7 @@ module Grip end # Sends a response with the content formated as json. - def json(content, content_type = "application/json; charset=UTF-8") + def json(content, content_type = "application/json") @response.headers.merge!({"Content-Type" => content_type}) @response.print(content.to_json) self