Skip to content

Commit

Permalink
Use put_resp_content_type which sets the charset to UTF-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
DevL committed Jun 6, 2015
1 parent 71a9d82 commit 93d61a9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/plug_require_header.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/plug_require_header_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 93d61a9

Please sign in to comment.