EventMachine & proxy requests

42 views
Skip to first unread message

Christoph Pilka

unread,
Apr 14, 2012, 8:13:42 PM4/14/12
to EventMachine
Hi folks,

I love EM, its performance is impressive. I'm coding on a distributed
harvester which uses few proxies. For me it's important to know which
request was sent via which proxy.But how to extract the proxy and
proxy port from the HTTP request? Didn't find any hint how to deal
with.

EventMachine.do
conn_opts = { :proxy => { :host => '1.2.3.4', :port => '8080' } }
request_opts = { :proxy => { :authorization => ['jdoe',
'mysecretpass'] } }
req = EventMachine::HttpRequest.new('http://www.example.com',
conn_opts).get request_opts
req.callback {
proxy = how_to_retrieve_proxy_from_req ?
port = same_for_port
puts "Request to #{req.last_effective_url} was sent via proxy
#{proxy}, port #{port}"
}
end

Cheerio,
Chris

Iñaki Baz Castillo

unread,
Apr 15, 2012, 9:15:11 AM4/15/12
to eventm...@googlegroups.com
2012/4/15 Christoph Pilka <c.p...@asconix.com>:

> EventMachine.do
>  conn_opts = { :proxy => { :host => '1.2.3.4', :port => '8080' } }
>  request_opts = { :proxy => { :authorization => ['jdoe',
> 'mysecretpass'] } }
>  req = EventMachine::HttpRequest.new('http://www.example.com',
> conn_opts).get request_opts
>  req.callback {
>    proxy = how_to_retrieve_proxy_from_req ?
>    port = same_for_port
>    puts "Request to #{req.last_effective_url} was sent via proxy
> #{proxy}, port #{port}"
>  }
> end

Hi, I don't understand the problem. You are passing { :host =>
'1.2.3.4', :port => '8080' } as the :proxy parameters so you DO know
those host and port values.

--
Iñaki Baz Castillo
<i...@aliax.net>

Reply all
Reply to author
Forward
0 new messages