Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/plug/conn/status.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}
]

Expand Down Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions test/plug/conn/status_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down