Skip to content

Commit

Permalink
x- prefix article
Browse files Browse the repository at this point in the history
  • Loading branch information
rnemeth90 committed Dec 28, 2023
1 parent 3e5d82d commit 7bfc271
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion content/posts/2023-11-01-http-headers-x-prefix.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ tags:

*Disclaimer: This article assumes you have some familiarity with the HTTP protocol in regards to headers.*

If you've worked in web development (or related roles) for any period of time, you have likely come across HTTP headers. There are common headers that you have likely seen, such as `host` or `content-type`, and others that you may be less familiar with.
If you've worked in web development (or related roles) for any period of time, you have likely come across HTTP headers. Headers are used to transmit metadata about a request or response between a client and server. There are common headers that you have likely seen, such as `host`, `content-type`, and `authorization`, and others that you may be less familiar with. One can also add custom headers, which is a common occurrence. Way back in 1982, the IETF published (RFC-822)[https://datatracker.ietf.org/doc/html/rfc822], which states any custom headers should be prefixed with `x-`. This worked fine for decades. Some of these `x-` headers became very popular and are now considered to be standard (`X-Forwarded-For`, `X-Forwarded-Host`, etc.). More of these can be seen (here)[https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers].

As X-prefixed headers gained popularity, the distinction between standard and non-standard headers became blurred. Standardization efforts should ideally remove the X- prefix, but this can lead to backward compatibility issues and break existing implementations. The `x-` headers cannot be used to distinguish between standard and non-standard headers anymore, which was their original intent. Therefore, we should stop using them. If you need to implement custom headers within your code, use a value unique to you. For example, you could prepend the header with your company name (common for application libraries). Example: `com.example.foo.myheader`

0 comments on commit 7bfc271

Please sign in to comment.