diff --git a/lib/phoenix/controller.ex b/lib/phoenix/controller.ex index 74f1d5bd46..b13ac956dc 100644 --- a/lib/phoenix/controller.ex +++ b/lib/phoenix/controller.ex @@ -1094,7 +1094,7 @@ defmodule Phoenix.Controller do conn else content_type = content_type <> "; charset=utf-8" - %Plug.Conn{conn | resp_headers: [{"content-type", content_type} | resp_headers]} + %{conn | resp_headers: [{"content-type", content_type} | resp_headers]} end end @@ -1323,7 +1323,7 @@ defmodule Phoenix.Controller do """ @spec scrub_params(Plug.Conn.t(), String.t()) :: Plug.Conn.t() - def scrub_params(conn, required_key) when is_binary(required_key) do + def scrub_params(%Plug.Conn{} = conn, required_key) when is_binary(required_key) do param = Map.get(conn.params, required_key) |> scrub_param() unless param do @@ -1331,7 +1331,7 @@ defmodule Phoenix.Controller do end params = Map.put(conn.params, required_key, param) - %Plug.Conn{conn | params: params} + %{conn | params: params} end defp scrub_param(%{__struct__: mod} = struct) when is_atom(mod) do diff --git a/lib/phoenix/endpoint/render_errors.ex b/lib/phoenix/endpoint/render_errors.ex index 3400399010..0e0d494bff 100644 --- a/lib/phoenix/endpoint/render_errors.ex +++ b/lib/phoenix/endpoint/render_errors.ex @@ -52,12 +52,12 @@ defmodule Phoenix.Endpoint.RenderErrors do end @doc false - def __catch__(conn, kind, reason, stack, opts) do + def __catch__(%Plug.Conn{} = conn, kind, reason, stack, opts) do conn = receive do @already_sent -> send(self(), @already_sent) - %Plug.Conn{conn | state: :sent} + %{conn | state: :sent} after 0 -> instrument_render_and_send(conn, kind, reason, stack, opts) @@ -126,13 +126,13 @@ defmodule Phoenix.Endpoint.RenderErrors do Controller.render(conn, template, assigns) end - defp maybe_fetch_query_params(conn) do + defp maybe_fetch_query_params(%Plug.Conn{} = conn) do fetch_query_params(conn) rescue Plug.Conn.InvalidQueryError -> case conn.params do - %Plug.Conn.Unfetched{} -> %Plug.Conn{conn | query_params: %{}, params: %{}} - params -> %Plug.Conn{conn | query_params: %{}, params: params} + %Plug.Conn.Unfetched{} -> %{conn | query_params: %{}, params: %{}} + params -> %{conn | query_params: %{}, params: params} end end