Is that something possible, i've been trying to get to the RAW headers sent during a GET request on a page, and couldn't find where. I'm using webrick. Here are the tries I did to get access to it: class ZController < ApplicationController def info #render :inline => request.inspect #render :inline => raw_header.inspect #render :inline => request_line.inspect #render :inline => req.inspect #render :inline => meta.inspect #render :inline => header.inspect #render :inline => headers.inspect # --> response headers #render :inline => $:.inspect #render :inline => $*.inspect #render :inline => $".inspect #render :inline => @request.inspect render :inline => inspect end end In the scope of the controller, I can't find such info. It seems it could be very useful but it would somewhat be corrupting the neat dependency on the CGI convention. I don't care too much about this, if it requires some tweaking of webrick or RoR, it's ok, but I would need to know what the simplest way. Thanks
on 2005-12-22 03:22
on 2005-12-22 03:34
Philippe L. wrote: > Is that something possible, i've been trying to get to the RAW headers > sent during a GET request on a page, and couldn't find where. I'm using > webrick. I forgot to explain what is really RAW: it's not request.env it's something that must look like: GET /Z/index HTTP/1.1 Host: localhost:3000 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050911 Firefox/1.0.6 (Debian package 1.0.6-5) Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Cookie: _session_id=049d26a05baf3d6048b153c50e29fed3 Cache-Control: max-age=0
on 2005-12-22 11:34
Rails runs in a CGI environment, where the Webserver provides various information with environment vars (and strips the headers from the request). For example, take FastCGI processes running seperately from the Webserver, where the Webserver just calls them. Rails never gets to see raw headers in the first place. (with FastCGI the enviroment vars are part of the FastCGI protocol). So, you have to stick to request.env, no raw headers here. For more on how the CGI protocol handles HTTP headers, look here: http://hoohoo.ncsa.uiuc.edu/cgi/env.html For a typical FastCGI call, see the first example here: http://www.fastcgi.com/devkit/doc/fcgi-spec.html#SB (notice how FCGI_PARAMS contains the stuff you'll find in request.env, and FCGI_STDIN contains nothing (it would only contain POST data, no headers)). -Thomas Am 22.12.2005 um 02:34 schrieb Philippe L.:
on 2005-12-22 12:27
Thomas F. wrote: > Rails runs in a CGI environment, where the Webserver provides > various information with environment vars (and strips the headers > from the request). [...] > > So, you have to stick to request.env, no raw headers here. > Except if I can stick to Webrick and do something custom for Webrick. My question is, if I want to do that, what's the best way? Can I create a do_GET handler for Webrick which still allows me to use the rest of rails with no problems? I wouldn't like it to be a quick hack but an extensible mechanism to blend in raw servlets and usual rails development. Thus, where should I modify my Webrick/actionpack scripts to insert this? Thanks, Philippe.