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

13 Answered Questions

[SOLVED] Are HTTPS URLs encrypted?

  • 2009-01-31 21:15:34
  • Daniel Kivatinos
  • 244923 View
  • 907 Score
  • 13 Answer
  • Tags:   ssl https httprequest

10 Answered Questions

[SOLVED] HTTP status code for update and delete?

6 Answered Questions

[SOLVED] Are HTTP headers case-sensitive?

  • 2011-03-10 11:22:16
  • Svish
  • 164543 View
  • 609 Score
  • 6 Answer
  • Tags:   http http-headers

24 Answered Questions

[SOLVED] HTTP GET request in JavaScript?

22 Answered Questions

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

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

18 Answered Questions

[SOLVED] HTTP GET with request body

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

19 Answered Questions

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

11 Answered Questions

6 Answered Questions

[SOLVED] Custom HTTP headers : naming conventions

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

8 Answered Questions

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

Sponsored Content