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?

2 comments

@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

19 Answered Questions

[SOLVED] How to make an HTTP POST request in node.js?

23 Answered Questions

[SOLVED] HTTP GET request in JavaScript?

13 Answered Questions

[SOLVED] Are HTTPS URLs encrypted?

22 Answered Questions

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

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

11 Answered Questions

11 Answered Questions

[SOLVED] What's the difference between a POST and a PUT HTTP REQUEST?

  • 2008-09-20 06:34:41
  • fuentesjr
  • 505000 View
  • 673 Score
  • 11 Answer
  • Tags:   http post put

5 Answered Questions

[SOLVED] Are HTTP headers case-sensitive?

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

6 Answered Questions

[SOLVED] Custom HTTP headers : naming conventions

  • 2010-08-24 21:59:38
  • Julien Genestoux
  • 297897 View
  • 930 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