Skip to content
Browse files

use env http_proxy for requests, if set

  • Loading branch information...
1 parent 8053d6f commit fa85372cc2da2ca77976b0e1a6b8f69041382037 @avonderluft committed Nov 10, 2011
Showing with 9 additions and 3 deletions.
  1. +9 −3 lib/rawler/request.rb
View
12 lib/rawler/request.rb
@@ -16,11 +16,17 @@ def head(url)
private
- def perform_request(method, url)
+ def perform_request(method, url)
uri = URI.parse(url)
- http = Net::HTTP.new(uri.host, uri.port)
- http.use_ssl = (uri.scheme == 'https')
+ # Use http_proxy if set
+ proxy = URI.parse(ENV['http_proxy']) if ENV['http_proxy'] rescue nil
+ if proxy
+ http = Net::HTTP::Proxy(proxy.host, proxy.port).new(uri.host, uri.port)
+ else
+ http = Net::HTTP.new(uri.host, uri.port)
+ end
+ http.use_ssl = (uri.scheme == 'https')
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
path = (uri.path.size == 0) ? "/" : uri.path

0 comments on commit fa85372

Please sign in to comment.
Something went wrong with that request. Please try again.