title: Error when trying to send HTTP status code in Phoenix
body: <p>I am a Phoenix/Elixir beginner and am trying to write an API to allow users to sign up in my application.</p>
  
  <p>The API endpoint works as expected unless I try to set the HTTP status code of the response. When I include lines A, B and C (indicated in the code below), I get a <code>FunctionClauseError</code> with the message <code>no function clause matching in :cowboy_req.status/1</code>.</p>
  
  <p>The complete error message is as follows:</p>
  
  <pre><code>[error] #PID&lt;0.344.0&gt; running App.Endpoint terminated
  Server: localhost:4000 (http)
  Request: POST /api/user/
  ** (exit) an exception was raised:
      ** (FunctionClauseError) no function clause matching in :cowboy_req.status/1
          (cowboy) src/cowboy_req.erl:1272: :cowboy_req.status(451)
          (cowboy) src/cowboy_req.erl:1202: :cowboy_req.response/6
          (cowboy) src/cowboy_req.erl:933: :cowboy_req.reply_no_compress/8
          (cowboy) src/cowboy_req.erl:888: :cowboy_req.reply/4
          (plug) lib/plug/adapters/cowboy/conn.ex:34: Plug.Adapters.Cowboy.Conn.send_resp/4
          (plug) lib/plug/conn.ex:356: Plug.Conn.send_resp/1
          (app) web/controllers/user_controller.ex:1: App.UserController.action/2
          (app) web/controllers/user_controller.ex:1: App.UserController.phoenix_controller_app/2
          (app) lib/app/endpoint.ex:1: App.Endpoint.instrument/4
          (app) lib/phoenix/router.ex:261: App.Router.dispatch/2
          (app) web/router.ex:1: App.Router.do_call/2
          (app) lib/app/endpoint.ex:1: App.Endpoint.phoenix_app/1
          (app) lib/plug/debugger.ex:122: App.Endpoint."call (overridable 3)"/2
          (app) lib/app/endpoint.ex:1: App.Endpoint.call/2
          (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
          (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
  </code></pre>
  
  <p>My code is as follows:</p>
  
  <pre><code>defmodule App.UserController do
    use App.Web, :controller
  
    import Ecto.Changeset
  
    alias App.User
    alias App.Session
  
    def create(conn, params) do
      changeset = User.changeset(%User{}, params)
  
      case Repo.insert(changeset) do
        {:ok, _user} -&gt;
          email = get_field(changeset, :email)
          password = get_field(changeset, :password)
  
          # Log on user upon sign up
          session_changeset = Session.changeset(%Session{
            email: email,
            password: password
          })
          result = Repo.insert(session_changeset)
  
          case result do
            {:ok, session} -&gt;
              conn
              |&gt; put_resp_cookie("SID", session.session_id)
              |&gt; put_status(201)  # line A
              |&gt; render("signup.json", data: %{
                   changeset: changeset
                 })
            {:error, changeset} -&gt;
              conn
              |&gt; put_status(251)  # line B
              |&gt; render("signup.json", data: %{
                   changeset: changeset
                 })
          end
        {:error, changeset} -&gt;
          conn
          |&gt; put_status(451)  # line C
          |&gt; render("signup.json", data: %{
               changeset: changeset
             })
      end
    end
  
  end
  </code></pre>
  
  <p>Why does this happen and where am I going wrong?</p>