By white

2014-04-04 07:19:38 8 Comments

Few month ago I had a problem with a custom HTTP header named "SESSION_ID", not been transfered by nginx proxy.

I've been told that underscores are prohibited according to RFC of HTTP protocol.

Googling, I've found that most servers like apache or nginx define them as illegal.

RFC2616 section 4.2 says

follow the same generic format as that given in Section 3.1 of RFC 822 [9]

and RFC822 says

The field-name must be composed of printable ASCII characters (i.e., characters that have values between 33. and 126., decimal, except colon)

underscore is 95 decimal character in ASCII table (belongs to 33-126 range). What am I missing?


@Alexey Ten 2014-04-04 07:58:30

They are not forbidden. It's CGI legacy. Here

If you do not explicitly set underscores_in_headers on;, nginx will silently drop HTTP headers with underscores (which are perfectly valid according to the HTTP standard). This is done in order to prevent ambiguities when mapping headers to CGI variables, as both dashes and underscores are mapped to underscores during that process.

@Qwertie 2017-08-30 00:49:57

Just spent hours debugging why my rails app works fine in development but not on production because of this :/

@Julian Reschke 2014-04-04 08:52:52

Underscores in header fields are allowed (RFC 7230, sec. 3.2.), but indeed uncommon.

Related Questions

Sponsored Content

18 Answered Questions

[SOLVED] HTTP GET with request body

  • 2009-06-10 20:47:24
  • Evert
  • 821429 View
  • 1664 Score
  • 18 Answer
  • Tags:   rest http http-get

22 Answered Questions

[SOLVED] How do I download a file over HTTP using Python?

  • 2008-08-22 15:34:13
  • Owen
  • 921963 View
  • 759 Score
  • 22 Answer
  • Tags:   python http urllib

13 Answered Questions

[SOLVED] Are HTTPS URLs encrypted?

24 Answered Questions

[SOLVED] HTTP GET request in JavaScript?

19 Answered Questions

[SOLVED] How is an HTTP POST request made in node.js?

5 Answered Questions

[SOLVED] Are HTTP headers case-sensitive?

  • 2011-03-10 11:22:16
  • Svish
  • 151285 View
  • 579 Score
  • 5 Answer
  • Tags:   http http-headers

11 Answered Questions

6 Answered Questions

[SOLVED] Custom HTTP headers : naming conventions

  • 2010-08-24 21:59:38
  • Julien Genestoux
  • 310588 View
  • 960 Score
  • 6 Answer
  • Tags:   http http-headers

8 Answered Questions

[SOLVED] HTTP status code for update and delete?

8 Answered Questions

[SOLVED] How are parameters sent in an HTTP POST request?

Sponsored Content