Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading header data in Ruby on Rails

I am making an API where in the access token for Facebook login will be sent in through header data.

How do I read this data from the header?

like image 427
abhilash Avatar asked Feb 06 '13 13:02

abhilash


1 Answers

request.headers["Content-Type"] # => "text/plain" 

replace "Content-Type" with the name of the header that you want to read.

Update for Rails 4.2

There are 2 ways to get them in Rails 4.2: Old way (still working):

request.headers["Cookie"] 

New way:

request.headers["HTTP_COOKIE"] 

To get a Hash with all headers of the request.

request.headers 
like image 94
Eduard Avatar answered Sep 23 '22 23:09

Eduard