hyperium / http

Rust HTTP types
Apache License 2.0
1.15k stars 285 forks source link

Rename 422 from "Unprocessable Entity" to "Unprocessable Content" #664

Open xpe opened 8 months ago

xpe commented 8 months ago

Present State

Currently: status.rs lines 456 to 458:

/// 422 Unprocessable Entity
/// [[RFC4918](https://tools.ietf.org/html/rfc4918)]
(422, UNPROCESSABLE_ENTITY, "Unprocessable Entity");

Recommendation

Use this instead:

/// 422 Unprocessable Content
/// [[RFC9110](https://datatracker.ietf.org/doc/html/rfc9110#section-15.5.21)]
(422, UNPROCESSABLE_CONTENT, "Unprocessable Content")

Relevant RFCs

Both of the following RFCs define 422 but with a one-word difference:

Potential Confusion: Even though RFC 9110 it is newer, it does not obsolete RFC 4918 (directly nor transitively).

Arguments in Favor of RFC 9110

  1. RFC 9110 is titled "HTTP Semantics" which is a direct fit for this library, whereas RFC 4918 is scoped to WebDAV.

  2. RFC 9110 is an Internet Standard while RFC 4918 is only a Proposed Standard.

  3. MDN uses RFC 9110 for the 422 status code

  4. RFC 9110 is newer (2022 vs. 2007)

RFC 9110: 422: Unprocessable Content

15.5.21. 422 Unprocessable Content

The 422 (Unprocessable Content) status code indicates that the server understands the content type of the request content (hence a 415 (Unsupported Media Type) status code is inappropriate), and the syntax of the request content is correct, but it was unable to process the contained instructions. For example, this status code can be sent if an XML request content contains well-formed (i.e., syntactically correct), but semantically erroneous XML instructions.

References