Wednesday, September 24, 2008

Variables In Request Env - Ruby on Rails

request.env is a Ruby Array that contains information about a visiting user’s and server environments.
request.env is accessible on all pages hosted in a ruby on rails site. The Array contains the following key/value pairs:

  • SERVER_NAME
  • PATH_INFO
  • REMOTE_HOST
  • HTTP_ACCEPT_ENCODING
  • HTTP_USER_AGENT
  • SERVER_PROTOCOL
  • HTTP_CACHE_CONTROL
  • HTTP_ACCEPT_LANGUAGE
  • HTTP_HOST
  • REMOTE_ADDR
  • SERVER_SOFTWARE
  • HTTP_KEEP_ALIVE
  • HTTP_REFERER
  • HTTP_COOKIE
  • HTTP_ACCEPT_CHARSET
  • REQUEST_URI
  • SERVER_PORT
  • GATEWAY_INTERFACE
  • QUERY_STRING
  • REMOTE_USER
  • HTTP_ACCEPT
  • REQUEST_METHOD
  • HTTP_CONNECTION
For testing purposes it might be useful to print out a table with the request.env information in it.

<table>
<th>key</th>
<th>Value</th>
<% for item in request.env %>
<tr>
<td><%= item[0] %></td>
<td><%= item[1] %></td>
</tr>
<% end %>
</table>

1 comment:

  1. Hi,

    Thanks you very much for this post. It is very useful for me.

    Once again Thanks,
    Kannan

    ReplyDelete

Contact Me for any help regarding rails/nodejs/php/mysql

Name

Email *

Message *