[Mongrel] Newbie Question: Can I setup mongrel as a proxy between a browser and the web?

Arash Nikkar anikkar at gmail.com
Wed Feb 6 14:32:16 EST 2008

I am trying to create a proxy which I can route my browser requests through
in order to gather information on the web page loading.  At this time I am
particularly interested in the many GET requests associated with loading a
single web page. Note: This does not have anything to do with rails, my goal
is to run a ruby app in the background, set firefox to proxy all requests
through it, log those requests, then return the fulfilled request back to
the browser (i.e. the web page still loads in the browser).

I posted this on a ruby forum, and it was suggested to do something along
the lines of:

require 'rubygems'
require 'mongrel'
require 'logger'

class HeaderHandler < Mongrel::HttpHandler

  @@logger = Logger.new('headers.log')

  def process(request,response)
    response.start(200) do |head, out|
      head["Content-Type"] = "text/plain"
      @@logger.info request.params

server = Mongrel::HttpServer.new("", "2222")
server.register("/", HeaderHandler.new)
server.register("/favicon.ico", Mongrel::Error404Handler.new(""))

The problem is that this only records the first request (i.e. google.com,
and not any other requests that are associated with loading that page), and
the page is never loaded in the browser as the requests is never actually

I have played around with this a bit, and tried changing some things up, but
I haven't really come up with anything. If anyone could point me in the
right direction, I would be grateful. Thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20080206/1249c858/attachment.html 

More information about the Mongrel-users mailing list