typhoeus 0.1.15 → 0.1.16

Sign up to get free protection for your applications and to get access to all the features.
data/lib/typhoeus.rb CHANGED
@@ -14,7 +14,7 @@ require 'typhoeus/request'
14
14
  require 'typhoeus/hydra'
15
15
 
16
16
  module Typhoeus
17
- VERSION = "0.1.14"
17
+ VERSION = "0.1.16"
18
18
 
19
19
  def self.easy_object_pool
20
20
  @easy_objects ||= []
data/lib/typhoeus/easy.rb CHANGED
@@ -20,7 +20,8 @@ module Typhoeus
20
20
  :CURLOPT_MAXREDIRS => 68,
21
21
  :CURLOPT_HTTPAUTH => 107,
22
22
  :CURLOPT_USERPWD => 10000 + 5,
23
- :CURLOPT_VERBOSE => 41
23
+ :CURLOPT_VERBOSE => 41,
24
+ :CURLOPT_PROXY => 10004
24
25
  }
25
26
  INFO_VALUES = {
26
27
  :CURLINFO_RESPONSE_CODE => 2097154,
@@ -45,6 +46,10 @@ module Typhoeus
45
46
  @headers = hash
46
47
  end
47
48
 
49
+ def proxy=(proxy)
50
+ set_option(OPTION_VALUES[:CURLOPT_PROXY], proxy)
51
+ end
52
+
48
53
  def auth=(authinfo)
49
54
  set_option(OPTION_VALUES[:CURLOPT_USERPWD], "#{authinfo[:username]}:#{authinfo[:password]}")
50
55
  set_option(OPTION_VALUES[:CURLOPT_HTTPAUTH], authinfo[:method]) if authinfo[:method]
@@ -124,6 +124,8 @@ module Typhoeus
124
124
  easy.timeout = request.timeout if request.timeout
125
125
  easy.follow_location = request.follow_location if request.follow_location
126
126
  easy.max_redirects = request.max_redirects if request.max_redirects
127
+ easy.proxy = request.proxy if request.proxy
128
+
127
129
  easy.on_success do |easy|
128
130
  queue_next
129
131
  handle_request(request, response_from_easy(easy, request))
@@ -1,6 +1,6 @@
1
1
  module Typhoeus
2
2
  class Request
3
- attr_accessor :method, :params, :body, :headers, :timeout, :user_agent, :response, :cache_timeout, :follow_location, :max_redirects
3
+ attr_accessor :method, :params, :body, :headers, :timeout, :user_agent, :response, :cache_timeout, :follow_location, :max_redirects, :proxy
4
4
  attr_reader :url
5
5
 
6
6
  def initialize(url, options = {})
@@ -13,6 +13,8 @@ module Typhoeus
13
13
  @cache_timeout = options[:cache_timeout]
14
14
  @follow_location = options[:follow_location]
15
15
  @max_redirects = options[:max_redirects]
16
+ @proxy = options[:proxy]
17
+
16
18
  if @method == :post
17
19
  @url = url
18
20
  else
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dix