sample/cookie.rb
raw| 1 | #!/usr/bin/env ruby |
| 2 | |
| 3 | $:.unshift(File.join('..', 'lib')) |
| 4 | require 'httpclient' |
| 5 | |
| 6 | proxy = ENV['HTTP_PROXY'] |
| 7 | clnt = HTTPClient.new(proxy) |
| 8 | clnt.set_cookie_store("cookie.dat") |
| 9 | clnt.debug_dev = STDOUT if $DEBUG |
| 10 | |
| 11 | while urlstr = ARGV.shift |
| 12 | response = clnt.get(urlstr){ |data| |
| 13 | print data |
| 14 | } |
| 15 | p response.contenttype |
| 16 | end |
| 17 | |
| 18 | clnt.save_cookie_store |