From 977e194a409017668c88eabeae43cc2806fc7531 Mon Sep 17 00:00:00 2001 From: Dylan Pulver Date: Thu, 3 Sep 2026 10:59:33 +0300 Subject: [PATCH] Use the RFC 9110 reason phrases for 413, 414 and 416 IANA's HTTP status code registry lists these as "Content Too Large", "URI Too Long" and "Range Not Satisfiable". RFC 9110 renamed all four of the phrases Plug carried from RFC 7231; 422 was updated in #1276 and these three were left behind. The old atoms are kept as aliases, using the same mechanism #1276 added, so put_status(:request_entity_too_large) keeps working. Co-authored-by: Claude --- lib/plug/conn/status.ex | 9 ++++++--- test/plug/conn/status_test.exs | 6 ++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/plug/conn/status.ex b/lib/plug/conn/status.ex index 5d269668..1993d2a3 100644 --- a/lib/plug/conn/status.ex +++ b/lib/plug/conn/status.ex @@ -6,6 +6,9 @@ defmodule Plug.Conn.Status do custom_statuses = Application.compile_env(:plug, :statuses, %{}) aliased_statuses = [ + {413, :request_entity_too_large}, + {414, :request_uri_too_long}, + {416, :requested_range_not_satisfiable}, {422, :unprocessable_entity} ] @@ -46,10 +49,10 @@ defmodule Plug.Conn.Status do 410 => "Gone", 411 => "Length Required", 412 => "Precondition Failed", - 413 => "Request Entity Too Large", - 414 => "Request-URI Too Long", + 413 => "Content Too Large", + 414 => "URI Too Long", 415 => "Unsupported Media Type", - 416 => "Requested Range Not Satisfiable", + 416 => "Range Not Satisfiable", 417 => "Expectation Failed", 418 => "I'm a teapot", 421 => "Misdirected Request", diff --git a/test/plug/conn/status_test.exs b/test/plug/conn/status_test.exs index ece213d3..5c9ec600 100644 --- a/test/plug/conn/status_test.exs +++ b/test/plug/conn/status_test.exs @@ -14,6 +14,9 @@ defmodule Plug.Conn.StatusTest do assert Status.code(:non_authoritative_information) == 203 assert Status.code(:not_found) == 404 assert Status.code(:unprocessable_content) == 422 + assert Status.code(:content_too_large) == 413 + assert Status.code(:uri_too_long) == 414 + assert Status.code(:range_not_satisfiable) == 416 end test "code for custom status return the numeric code" do @@ -22,6 +25,9 @@ defmodule Plug.Conn.StatusTest do test "code for aliased statuses" do assert Status.code(:unprocessable_entity) == 422 + assert Status.code(:request_entity_too_large) == 413 + assert Status.code(:request_uri_too_long) == 414 + assert Status.code(:requested_range_not_satisfiable) == 416 end test "code with both a built_in and custom code return the numeric code" do