title: Accessing custom header variables in Ruby on Rails
body: <p>After reading the following question (<a href="https://stackoverflow.com/questions/2311883/authorization-header-in-ruby-on-rails-accessed-with-key-http-authorization-inste">Authorization header in Ruby on Rails accessed with key HTTP_AUTHORIZATION instead of Authorization?</a>) I have a similar problem as the OP, but the proposed answer does not seem to solve mine.</p>
  
  <p>I define a custom header as such in a call to my locally hosted server (through Postman):</p>
  
  <p>@Igor: I actually use Postman, so I just added the curl code to demonstrate what I did. I guess it would be better to include a screenshot:</p>
  
  <p><img src="https://i.stack.imgur.com/elGeL.png" alt="enter image description here"></p>
  
  <p>And this is the code in my controller which tries to read said header:</p>
  
  <pre><code>def authenticate_through_header
    custom_header_value = request.headers['custom_header']
  end
  </code></pre>
  
  <p>However, this return <code>nil</code>. On the other hand, <code>request.headers['HTTP_CUSTOM_HEADER']</code> returns the value. According to the question I linked to initially, I should be able to get the value through passing the name within the brackets [ ] - is this something which has been changed in newer Rails versions?</p>
  
  <p>Cheers :-)</p>
  
  <p><em>Update</em>: It also works to access the variable in the following way: <code>request.headers['custom-header']</code>. So apparently it works to replace the underscore with a hyphen, which seems weird.</p>