diff --git a/lib/plug_require_header.ex b/lib/plug_require_header.ex index dabb924..4647545 100644 --- a/lib/plug_require_header.ex +++ b/lib/plug_require_header.ex @@ -97,14 +97,14 @@ defmodule PlugRequireHeader do conn else conn - |> put_resp_header("content-type", content_type_for(format)) + |> put_resp_content_type(content_type_for format) |> send_resp(status, format_message(message, format)) |> halt end end end - defp content_type_for(:text), do: "text/plain; charset=utf-8" + defp content_type_for(:text), do: "text/plain" defp content_type_for(:json), do: "application/json" defp format_message(message, :text), do: message diff --git a/test/plug_require_header_test.exs b/test/plug_require_header_test.exs index 4eaf769..dfffc03 100644 --- a/test/plug_require_header_test.exs +++ b/test/plug_require_header_test.exs @@ -99,7 +99,7 @@ defmodule PlugRequireHeaderTest do assert response.status == 418 assert response.resp_body == Poison.encode! %{error: "I'm a teapot!"} - assert content_type(response) == "application/json" + assert content_type(response) == "application/json; charset=utf-8" end defp content_type(response) do