Forum: Ruby HTTP Proxy instruction?

Posted by Ben Weeks (Guest)
on 2008-01-22 17:49
(Received via mailing list)
I'm looking to create a proxy that will scrape all my http headers and
post them to stdout. My searches have been vacant on this topic, does
anybody know of any good tutorials out there?

-Ben
Posted by Joel VanderWerf (Guest)
on 2008-01-22 19:57
(Received via mailing list)
Ben Weeks wrote:
> I'm looking to create a proxy that will scrape all my http headers and
> post them to stdout. My searches have been vacant on this topic, does
> anybody know of any good tutorials out there?

One place to look is the httpproxy.rb that comes with webrick in the
standard ruby libs. No tutorial AFAIK, but it's fairly simple code.
Posted by Francis Cianfrocca (blackhedd)
on 2008-01-23 13:59
(Received via mailing list)
On Jan 22, 2008 11:48 AM, Ben Weeks <bweeks@gmail.com> wrote:

> I'm looking to create a proxy that will scrape all my http headers and
> post them to stdout. My searches have been vacant on this topic, does
> anybody know of any good tutorials out there?
>



Do you need a forward proxy or a reverse proxy? Does it need to be
transparent (which would require some kind of address translation) or do 
you
want the ordinary HTTP-proxy kind?
Posted by GOTO Kentaro (Guest)
on 2008-01-23 14:23
(Received via mailing list)
On Jan 23, 2008 1:48 AM, Ben Weeks <bweeks@gmail.com> wrote:
> I'm looking to create a proxy that will scrape all my http headers and
> post them to stdout. My searches have been vacant on this topic, does
> anybody know of any good tutorials out there?

Try this one-liner,

% ruby -r webrick/httpproxy -e 's = WEBrick::HTTPProxyServer.new(:Port
=> 9999, :RequestCallback => Proc.new{|req,res| puts req.request_line,
req.raw_header}); trap("INT"){s.shutdown}; s.start'

webrick/httprequest.rb defines APIs of a req object.


HTH

Gotoken
Posted by Ben Weeks (Guest)
on 2008-01-23 20:24
(Received via mailing list)
That's the perfect starting point.  Thanks Gotoken and everybody else.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.