typhoeus 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,10 @@
1
- 0.3.0
1
+ 0.3.3
2
+ --------------
3
+ * Make sure to call the Easy::failure callback on all non-success http response codes, even invalid ones. [balexis]
4
+ * Use bytesize instead of length to determine Content-Length [dlamacchia]
5
+ * Added SSL version option to Easy/Request [michelbarbosa/dbalatero]
6
+
7
+ 0.3.2
2
8
  -----
3
9
  * Fix array params to be consistent with HTTP spec [gridaphobe]
4
10
  * traversal_to_params_hash should use the escape option [itsmeduncan]
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- typhoeus (0.3.0)
4
+ typhoeus (0.3.2)
5
5
  mime-types
6
6
 
7
7
  GEM
@@ -11,6 +11,7 @@ GEM
11
11
  json (1.5.3)
12
12
  mime-types (1.16)
13
13
  rack (1.3.0)
14
+ rake (0.9.2)
14
15
  rspec (2.6.0)
15
16
  rspec-core (~> 2.6.0)
16
17
  rspec-expectations (~> 2.6.0)
@@ -30,6 +31,7 @@ PLATFORMS
30
31
  DEPENDENCIES
31
32
  diff-lcs
32
33
  json
34
+ rake
33
35
  rspec (~> 2.6)
34
36
  sinatra
35
37
  typhoeus!
data/Rakefile CHANGED
@@ -1,29 +1,5 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
 
3
- require "lib/typhoeus/version"
4
-
5
- begin
6
- require 'jeweler'
7
- Jeweler::Tasks.new do |gemspec|
8
- gemspec.name = "typhoeus"
9
- gemspec.summary = "A library for interacting with web services (and building SOAs) at blinding speed."
10
- gemspec.description = "Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic."
11
- gemspec.email = "dbalatero@gmail.com"
12
- gemspec.homepage = "http://github.com/dbalatero/typhoeus"
13
- gemspec.authors = ["Paul Dix", "David Balatero"]
14
- gemspec.add_dependency "mime-types"
15
- gemspec.add_development_dependency "rspec", "~> 2.6"
16
- gemspec.add_development_dependency "jeweler"
17
- gemspec.add_development_dependency "diff-lcs"
18
- gemspec.add_development_dependency "sinatra"
19
- gemspec.add_development_dependency "json"
20
- end
21
-
22
- Jeweler::GemcutterTasks.new
23
- rescue LoadError
24
- puts "Jeweler not available. Install it with: gem install jeweler"
25
- end
26
-
27
3
  require 'rspec/core/rake_task'
28
4
  RSpec::Core::RakeTask.new do |t|
29
5
  end
@@ -36,18 +12,32 @@ end
36
12
 
37
13
  desc "Builds the native code"
38
14
  task :build_native do
39
- system("cd ext/typhoeus && ruby extconf.rb && make")
15
+ system("cd ext/typhoeus && ruby extconf.rb && make clean && make")
40
16
  end
41
17
 
42
18
  desc "Start up the test servers"
43
19
  task :start_test_servers do
44
20
  puts "Starting 3 test servers"
45
- (3000..3002).map do |port|
46
- Thread.new do
47
- system("ruby spec/servers/app.rb -p #{port}")
21
+
22
+ pids = []
23
+ [3000, 3001, 3002].each do |port|
24
+ if pid = fork
25
+ pids << pid
26
+ else
27
+ exec('ruby', 'spec/servers/app.rb', '-p', port.to_s)
48
28
  end
49
- end.each(&:join)
29
+ end
30
+
31
+ at_exit do
32
+ pids.each do |pid|
33
+ puts "Killing pid #{pid}"
34
+ Process.kill("KILL", pid)
35
+ end
36
+ end
37
+
38
+ # Wait for kill.
39
+ sleep
50
40
  end
51
41
 
52
- desc "Run all the tests"
53
- task :default => :spec
42
+ desc "Build Typhoeus and run all the tests."
43
+ task :default => [:build_native, :spec]
@@ -92,7 +92,7 @@ static void multi_read_info(VALUE self, CURLM *multi_handle) {
92
92
  else if ((response_code >= 200 && response_code < 300) || response_code == 0) {
93
93
  rb_funcall(easy, rb_intern("success"), 0);
94
94
  }
95
- else if (response_code >= 300 && response_code < 600) {
95
+ else {
96
96
  rb_funcall(easy, rb_intern("failure"), 0);
97
97
  }
98
98
  }
@@ -1,6 +1,6 @@
1
1
  module Typhoeus
2
2
  class Easy
3
- attr_reader :response_body, :response_header, :method, :headers, :url, :params, :curl_return_code
3
+ attr_reader :response_body, :response_header, :method, :headers, :url, :params, :curl_return_code, :ssl_version
4
4
  attr_accessor :start_time
5
5
 
6
6
  # These integer codes are available in curl/curl.h
@@ -40,6 +40,7 @@ module Typhoeus
40
40
  :CURLOPT_SSLCERTTYPE => 10086,
41
41
  :CURLOPT_SSLKEY => 10087,
42
42
  :CURLOPT_SSLKEYTYPE => 10088,
43
+ :CURLOPT_SSLVERSION => 32,
43
44
  :CURLOPT_KEYPASSWD => 10026,
44
45
  :CURLOPT_CAINFO => 10065,
45
46
  :CURLOPT_CAPATH => 10097,
@@ -73,6 +74,16 @@ module Typhoeus
73
74
  :CURLPROXY_SOCKS4A => 6,
74
75
  }
75
76
 
77
+ SSL_VERSIONS = {
78
+ :CURL_SSLVERSION_DEFAULT => 0,
79
+ :CURL_SSLVERSION_TLSv1 => 1,
80
+ :CURL_SSLVERSION_SSLv2 => 2,
81
+ :CURL_SSLVERSION_SSLv3 => 3,
82
+ :default => 0,
83
+ :tlsv1 => 1,
84
+ :sslv2 => 2,
85
+ :sslv3 => 3
86
+ }
76
87
 
77
88
  def initialize
78
89
  @method = :get
@@ -83,13 +94,26 @@ module Typhoeus
83
94
 
84
95
  def set_defaults
85
96
  # Enable encoding/compression support
86
- set_option(OPTION_VALUES[:CURLOPT_ENCODING], '')
97
+ self.encoding = ''
98
+ self.ssl_version = :default
99
+ end
100
+
101
+ def encoding=(encoding)
102
+ # Enable encoding/compression support
103
+ set_option(OPTION_VALUES[:CURLOPT_ENCODING], encoding)
104
+ end
105
+
106
+ def ssl_version=(version)
107
+ raise "Invalid SSL version: '#{version}' supplied! Please supply one as listed in Typhoeus::Easy::SSL_VERSIONS" unless SSL_VERSIONS.has_key?(version)
108
+ @ssl_version = version
109
+
110
+ set_option(OPTION_VALUES[:CURLOPT_SSLVERSION], SSL_VERSIONS[version])
87
111
  end
88
112
 
89
113
  def headers=(hash)
90
114
  @headers = hash
91
115
  end
92
-
116
+
93
117
  def interface=(interface)
94
118
  @interface = interface
95
119
  set_option(OPTION_VALUES[:CURLOPT_INTERFACE], interface)
@@ -145,7 +169,7 @@ module Typhoeus
145
169
  def effective_url
146
170
  get_info_string(INFO_VALUES[:CURLINFO_EFFECTIVE_URL])
147
171
  end
148
-
172
+
149
173
  def primary_ip
150
174
  get_info_string(INFO_VALUES[:CURLINFO_PRIMARY_IP])
151
175
  end
@@ -231,7 +255,7 @@ module Typhoeus
231
255
 
232
256
  def post_data=(data)
233
257
  @post_data_set = true
234
- set_option(OPTION_VALUES[:CURLOPT_POSTFIELDSIZE], data.length)
258
+ set_option(OPTION_VALUES[:CURLOPT_POSTFIELDSIZE], data.bytesize)
235
259
  set_option(OPTION_VALUES[:CURLOPT_COPYPOSTFIELDS], data)
236
260
  end
237
261
 
@@ -332,7 +356,8 @@ module Typhoeus
332
356
  easy_set_headers() unless headers.empty?
333
357
  end
334
358
 
335
- # gets called when finished and response code is 200-299
359
+ # gets called when finished and response code is not 2xx,
360
+ # or curl returns an error code.
336
361
  def success
337
362
  @success.call(self) if @success
338
363
  end
@@ -345,7 +370,8 @@ module Typhoeus
345
370
  @success = block
346
371
  end
347
372
 
348
- # gets called when finished and response code is 300-599 or curl returns an error code
373
+ # gets called when finished and response code is 300-599
374
+ # or curl returns an error code
349
375
  def failure
350
376
  @failure.call(self) if @failure
351
377
  end
@@ -178,6 +178,7 @@ module Typhoeus
178
178
  easy.ssl_key_password = request.ssl_key_password
179
179
  easy.ssl_cacert = request.ssl_cacert
180
180
  easy.ssl_capath = request.ssl_capath
181
+ easy.ssl_version = request.ssl_version || :default
181
182
  easy.verbose = request.verbose
182
183
 
183
184
  easy.on_success do |easy|
@@ -2,16 +2,43 @@ require 'uri'
2
2
 
3
3
  module Typhoeus
4
4
  class Request
5
+ ACCESSOR_OPTIONS = [
6
+ :method,
7
+ :params,
8
+ :body,
9
+ :headers,
10
+ :connect_timeout,
11
+ :timeout,
12
+ :user_agent,
13
+ :response,
14
+ :cache_timeout,
15
+ :follow_location,
16
+ :max_redirects,
17
+ :proxy,
18
+ :proxy_username,
19
+ :proxy_password,
20
+ :disable_ssl_peer_verification,
21
+ :disable_ssl_host_verification,
22
+ :interface,
23
+ :ssl_cert,
24
+ :ssl_cert_type,
25
+ :ssl_key,
26
+ :ssl_key_type,
27
+ :ssl_key_password,
28
+ :ssl_cacert,
29
+ :ssl_capath,
30
+ :ssl_version,
31
+ :verbose,
32
+ :username,
33
+ :password,
34
+ :auth_method,
35
+ :user_agent,
36
+ :proxy_auth_method,
37
+ :proxy_type
38
+ ]
39
+
5
40
  attr_reader :url
6
- attr_writer :headers
7
- attr_accessor :method, :params, :body, :connect_timeout, :timeout,
8
- :user_agent, :response, :cache_timeout, :follow_location,
9
- :max_redirects, :proxy, :proxy_username,:proxy_password,
10
- :disable_ssl_peer_verification, :disable_ssl_host_verification, :interface,
11
- :ssl_cert, :ssl_cert_type, :ssl_key, :ssl_key_type,
12
- :ssl_key_password, :ssl_cacert, :ssl_capath, :verbose,
13
- :username, :password, :auth_method, :user_agent,
14
- :proxy_auth_method, :proxy_type
41
+ attr_accessor *ACCESSOR_OPTIONS
15
42
 
16
43
  # Initialize a new Request
17
44
  #
@@ -25,7 +52,6 @@ module Typhoeus
25
52
  # ** +:interface+ : interface or ip address (string)
26
53
  # ** +:connect_timeout+ : connect timeout (ms)
27
54
  # ** +:headers+ : headers as Hash
28
- # ** +:user_agent+ : user agent (string)
29
55
  # ** +:cache_timeout+ : cache timeout (ms)
30
56
  # ** +:follow_location
31
57
  # ** +:max_redirects
@@ -43,6 +69,7 @@ module Typhoeus
43
69
  # ** +:username
44
70
  # ** +:password
45
71
  # ** +:auth_method
72
+ # ** +:user_agent+ : user agent (string) - DEPRECATED
46
73
  #
47
74
  def initialize(url, options = {})
48
75
  @method = options[:method] || :get
@@ -52,7 +79,11 @@ module Typhoeus
52
79
  @connect_timeout = safe_to_i(options[:connect_timeout])
53
80
  @interface = options[:interface]
54
81
  @headers = options[:headers] || {}
55
- @user_agent = options[:user_agent] || Typhoeus::USER_AGENT
82
+
83
+ if options.has_key?(:user_agent)
84
+ self.user_agent = options[:user_agent]
85
+ end
86
+
56
87
  @cache_timeout = safe_to_i(options[:cache_timeout])
57
88
  @follow_location = options[:follow_location]
58
89
  @max_redirects = options[:max_redirects]
@@ -70,6 +101,7 @@ module Typhoeus
70
101
  @ssl_key_password = options[:ssl_key_password]
71
102
  @ssl_cacert = options[:ssl_cacert]
72
103
  @ssl_capath = options[:ssl_capath]
104
+ @ssl_version = options[:ssl_version]
73
105
  @verbose = options[:verbose]
74
106
  @username = options[:username]
75
107
  @password = options[:password]
@@ -94,6 +126,15 @@ module Typhoeus
94
126
  LOCALHOST_ALIASES.include?(@parsed_uri.host)
95
127
  end
96
128
 
129
+ def user_agent
130
+ headers['User-Agent']
131
+ end
132
+
133
+ def user_agent=(value)
134
+ puts "DEPRECATED: Typhoeus::Request#user_agent=(value). This will be removed in a later version."
135
+ headers['User-Agent'] = value
136
+ end
137
+
97
138
  def host
98
139
  slash_location = @url.index('/', 8)
99
140
  if slash_location
@@ -108,11 +149,6 @@ module Typhoeus
108
149
  @parsed_uri.host
109
150
  end
110
151
 
111
- def headers
112
- @headers["User-Agent"] = @user_agent
113
- @headers
114
- end
115
-
116
152
  def params_string
117
153
  traversal = Typhoeus::Utils.traverse_params_hash(params)
118
154
  Typhoeus::Utils.traversal_to_param_string(traversal)
@@ -217,6 +253,10 @@ module Typhoeus
217
253
  attributes.each { |name, value| instance_variable_set(name, value) }
218
254
  end
219
255
 
256
+ def self.options
257
+ ACCESSOR_OPTIONS
258
+ end
259
+
220
260
  private
221
261
 
222
262
  def safe_to_i(value)
@@ -1,3 +1,3 @@
1
1
  module Typhoeus
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -4,6 +4,8 @@ require 'sinatra'
4
4
  require 'json'
5
5
  require 'zlib'
6
6
 
7
+ set :logging, false
8
+
7
9
  @@fail_count = 0
8
10
 
9
11
  post '/file' do
@@ -83,16 +85,13 @@ head '/**' do
83
85
  end
84
86
 
85
87
  put '/**' do
86
- puts request.inspect
87
88
  request.env.merge!(:body => request.body.read).to_json
88
89
  end
89
90
 
90
91
  post '/**' do
91
- puts request.inspect
92
92
  request.env.merge!(:body => request.body.read).to_json
93
93
  end
94
94
 
95
95
  delete '/**' do
96
- puts request.inspect
97
96
  request.env.merge!(:body => request.body.read).to_json
98
97
  end
@@ -10,5 +10,10 @@ $LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path)
10
10
 
11
11
  require path + '/typhoeus'
12
12
 
13
+ Dir['./spec/support/**/*.rb'].each { |f| require f }
14
+
13
15
  RSpec.configure do |config|
16
+ config.before(:suite) do
17
+ TyphoeusLocalhostServer.start_servers!
18
+ end
14
19
  end
@@ -0,0 +1,58 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+
4
+ class TyphoeusLocalhostServer
5
+ class << self
6
+ attr_accessor :pid
7
+
8
+ def start_servers!
9
+ if self.pid = fork
10
+ start_parent
11
+ wait_for_servers_to_start
12
+ else
13
+ start_child
14
+ end
15
+ end
16
+
17
+ private
18
+
19
+ def start_parent
20
+ # Cleanup.
21
+ at_exit do
22
+ Process.kill('QUIT', self.pid) if self.pid
23
+ end
24
+ end
25
+
26
+ def start_child
27
+ exec('rake', 'start_test_servers')
28
+ end
29
+
30
+ def wait_for_servers_to_start
31
+ puts "Waiting for servers to start..."
32
+ ports = [3000, 3001, 3002]
33
+
34
+ Timeout::timeout(10) do
35
+ loop do
36
+ up = 0
37
+ ports.each do |port|
38
+ url = "http://localhost:#{port}/"
39
+ begin
40
+ response = Net::HTTP.get_response(URI.parse(url))
41
+ if response.is_a?(Net::HTTPSuccess)
42
+ up += 1
43
+ end
44
+ rescue SystemCallError => error
45
+ end
46
+ end
47
+
48
+ if up == ports.size
49
+ puts "Servers are up!"
50
+ break
51
+ end
52
+ end
53
+ end
54
+ rescue Timeout::Error => error
55
+ abort "Servers never started!"
56
+ end
57
+ end
58
+ end
@@ -1,6 +1,37 @@
1
+ # encoding: UTF-8
1
2
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
3
 
4
+ if defined?(Encoding)
5
+ Encoding.default_internal = 'utf-8'
6
+ Encoding.default_external = 'utf-8'
7
+ end
8
+
3
9
  describe Typhoeus::Easy do
10
+ describe "ssl_version" do
11
+ before(:each) do
12
+ @easy = Typhoeus::Easy.new
13
+ @easy.url = "http://localhost:3000"
14
+ @easy.method = :get
15
+ end
16
+
17
+ it "should allow to set the SSL version to be used" do
18
+ Typhoeus::Easy::SSL_VERSIONS.each do |k, v|
19
+ @easy.ssl_version = k
20
+ @easy.perform
21
+ @easy.response_code.should == 200
22
+ @easy.ssl_version.should == k
23
+ end
24
+ end
25
+
26
+ it "complains when an incorrect SSL version is used" do
27
+ expect { @easy.ssl_version = 'bogus' }.to raise_error
28
+ end
29
+
30
+ it "uses the default SSL version if nothing is supplied" do
31
+ @easy.ssl_version.should == :default
32
+ end
33
+ end
34
+
4
35
  describe "#supports_zlib" do
5
36
  before(:each) do
6
37
  @easy = Typhoeus::Easy.new
@@ -76,7 +107,7 @@ describe Typhoeus::Easy do
76
107
  e = Typhoeus::Easy.new
77
108
  e.url = "http://localhost:3002"
78
109
  e.method = :get
79
- e.user_agent = "myapp"
110
+ e.headers['User-Agent'] = 'myapp'
80
111
  e.perform
81
112
  e.response_code.should == 200
82
113
  JSON.parse(e.response_body)["HTTP_USER_AGENT"].should == "myapp"
@@ -120,7 +151,7 @@ describe Typhoeus::Easy do
120
151
  e.primary_ip.should == "127.0.0.1"
121
152
  end
122
153
  end
123
-
154
+
124
155
  describe "authentication" do
125
156
  it "should allow to set username and password" do
126
157
  e = Typhoeus::Easy.new
@@ -131,7 +162,7 @@ describe Typhoeus::Easy do
131
162
  e.perform
132
163
  e.response_code.should == 200
133
164
  end
134
-
165
+
135
166
  it "should allow to query auth methods support by the server" do
136
167
  e = Typhoeus::Easy.new
137
168
  e.url = "http://localhost:3001/auth_basic/foo/bar"
@@ -149,7 +180,7 @@ describe Typhoeus::Easy do
149
180
  e.response_code.should == 200
150
181
  end
151
182
  end
152
-
183
+
153
184
  describe "get" do
154
185
  it "should perform a get" do
155
186
  easy = Typhoeus::Easy.new
@@ -213,7 +244,7 @@ describe Typhoeus::Easy do
213
244
  easy.response_code.should == 200
214
245
  JSON.parse(easy.response_body)["REQUEST_METHOD"].should == "PUT"
215
246
  end
216
-
247
+
217
248
  it "should send a request body" do
218
249
  easy = Typhoeus::Easy.new
219
250
  easy.url = "http://localhost:3002"
@@ -241,8 +272,17 @@ describe Typhoeus::Easy do
241
272
  JSON.parse(easy.response_body)["REQUEST_METHOD"].should == "PUT"
242
273
  end
243
274
 
275
+ it "should set content length correctly for a utf-8 string" do
276
+ body = "this is a body with utf-8 content: Motörhead! WHÖÖ!"
277
+ easy = Typhoeus::Easy.new
278
+ easy.url = "http://localhost:3002"
279
+ easy.method = :post
280
+ easy.should_receive(:set_option).with(Typhoeus::Easy::OPTION_VALUES[:CURLOPT_POSTFIELDSIZE], 55)
281
+ easy.should_receive(:set_option).with(Typhoeus::Easy::OPTION_VALUES[:CURLOPT_COPYPOSTFIELDS], body)
282
+ easy.request_body = body
283
+ end
244
284
  end
245
-
285
+
246
286
  describe "post" do
247
287
  it "should perform a post" do
248
288
  easy = Typhoeus::Easy.new
@@ -252,7 +292,7 @@ describe Typhoeus::Easy do
252
292
  easy.response_code.should == 200
253
293
  JSON.parse(easy.response_body)["REQUEST_METHOD"].should == "POST"
254
294
  end
255
-
295
+
256
296
  it "should send a request body" do
257
297
  easy = Typhoeus::Easy.new
258
298
  easy.url = "http://localhost:3002"
@@ -262,7 +302,7 @@ describe Typhoeus::Easy do
262
302
  easy.response_code.should == 200
263
303
  easy.response_body.should include("this is a body!")
264
304
  end
265
-
305
+
266
306
  it "should handle params" do
267
307
  easy = Typhoeus::Easy.new
268
308
  easy.url = "http://localhost:3002"
@@ -282,7 +322,7 @@ describe Typhoeus::Easy do
282
322
  easy.perform
283
323
 
284
324
  request = JSON.parse(easy.response_body)
285
- request['CONTENT_TYPE'].should == 'application/x-www-form-urlencoded'
325
+ request['CONTENT_TYPE'].should == 'application/x-www-form-urlencoded'
286
326
  request['rack.request.form_vars'].should == 'a=b&c=d&e[f][g]=h'
287
327
  end
288
328
 
@@ -294,7 +334,7 @@ describe Typhoeus::Easy do
294
334
  easy.perform
295
335
  easy.response_code.should == 200
296
336
  result = JSON.parse(easy.response_body)
297
-
337
+
298
338
  { 'content-type' => 'text/plain',
299
339
  'filename' => 'placeholder.txt',
300
340
  'content' => 'This file is used to test uploading.'
@@ -305,7 +345,7 @@ describe Typhoeus::Easy do
305
345
  result['request-content-type'].should =~ /multipart/
306
346
  end
307
347
  end
308
-
348
+
309
349
  describe "delete" do
310
350
  it "should perform a delete" do
311
351
  easy = Typhoeus::Easy.new
@@ -315,7 +355,7 @@ describe Typhoeus::Easy do
315
355
  easy.response_code.should == 200
316
356
  JSON.parse(easy.response_body)["REQUEST_METHOD"].should == "DELETE"
317
357
  end
318
-
358
+
319
359
  it "should send a request body" do
320
360
  easy = Typhoeus::Easy.new
321
361
  easy.url = "http://localhost:3002"
@@ -326,9 +366,9 @@ describe Typhoeus::Easy do
326
366
  easy.response_body.should include("this is a body!")
327
367
  end
328
368
  end
329
-
369
+
330
370
  describe "encoding/compression support" do
331
-
371
+
332
372
  it "should send valid encoding headers and decode the response" do
333
373
  easy = Typhoeus::Easy.new
334
374
  easy.url = "http://localhost:3002/gzipped"
@@ -347,6 +387,5 @@ describe Typhoeus::Easy do
347
387
  easy.response_code.should == 200
348
388
  JSON.parse(easy.response_body)["HTTP_ACCEPT_ENCODING"].should == "deflate, gzip"
349
389
  end
350
-
351
390
  end
352
391
  end
@@ -65,7 +65,7 @@ describe Typhoeus::HydraMock do
65
65
  :headers => { 'user-agent' => 'test' })
66
66
  request = Typhoeus::Request.new('http://www.example.com/',
67
67
  :method => :get,
68
- :user_agent => 'test')
68
+ :headers => { 'user-agent' => 'test' })
69
69
  mock.matches?(request).should be_true
70
70
  end
71
71
 
@@ -74,7 +74,7 @@ describe Typhoeus::HydraMock do
74
74
  :headers => { 'user-agent' => 'test' })
75
75
  request = Typhoeus::Request.new('https://www.example.com/',
76
76
  :method => :get,
77
- :user_agent => 'test')
77
+ :headers => { 'user-agent' => 'test' })
78
78
  mock.matches?(request).should be_true
79
79
  end
80
80
  end
@@ -87,7 +87,7 @@ describe Typhoeus::HydraMock do
87
87
  [:get, :post, :delete, :put].each do |verb|
88
88
  request = Typhoeus::Request.new("http://localhost:3000",
89
89
  :method => verb,
90
- :user_agent => 'test')
90
+ :headers => { 'user-agent' => 'test' })
91
91
  mock.matches?(request).should be_true
92
92
  end
93
93
  end
@@ -248,7 +248,7 @@ describe Typhoeus::HydraMock do
248
248
  it "should not bother matching on body if we don't turn the option on" do
249
249
  request = Typhoeus::Request.new("http://localhost:3000",
250
250
  :method => :get,
251
- :user_agent => 'test',
251
+ :headers => { 'user-agent' => 'test' },
252
252
  :body => "fdsafdsa")
253
253
  mock = Typhoeus::HydraMock.new("http://localhost:3000", :get,
254
254
  :headers => { 'user-agent' => 'test' })
@@ -276,7 +276,7 @@ describe Typhoeus::HydraMock do
276
276
  it "should match on optional body parameter" do
277
277
  request = Typhoeus::Request.new("http://localhost:3000",
278
278
  :method => :get,
279
- :user_agent => 'test',
279
+ :headers => { 'user-agent' => 'test' },
280
280
  :body => "fdsafdsa")
281
281
  mock = Typhoeus::HydraMock.new("http://localhost:3000", :get,
282
282
  :body => 'fdsafdsa',
@@ -289,7 +289,7 @@ describe Typhoeus::HydraMock do
289
289
  it "should regex match" do
290
290
  request = Typhoeus::Request.new("http://localhost:3000/whatever/fdsa",
291
291
  :method => :get,
292
- :user_agent => 'test')
292
+ :headers => { 'user-agent' => 'test' })
293
293
  mock = Typhoeus::HydraMock.new(/fdsa/, :get,
294
294
  :headers => { 'user-agent' => 'test' })
295
295
  mock.matches?(request).should be_true
@@ -334,7 +334,7 @@ describe Typhoeus::Hydra::Stubbing do
334
334
  before(:each) do
335
335
  @on_complete_handler_called = nil
336
336
  @request = Typhoeus::Request.new("http://localhost:3000/foo",
337
- :user_agent => 'test')
337
+ :headers => { 'user-agent' => 'test' })
338
338
  @request.on_complete do |response|
339
339
  @on_complete_handler_called = true
340
340
  response.code.should == 404
@@ -29,4 +29,5 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency 'diff-lcs', [">= 0"]
30
30
  s.add_development_dependency 'sinatra', [">= 0"]
31
31
  s.add_development_dependency 'json', [">= 0"]
32
+ s.add_development_dependency 'rake', [">= 0"]
32
33
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: typhoeus
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Balatero
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-10-18 00:00:00 Z
19
+ date: 2011-11-17 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  name: mime-types
@@ -89,6 +89,20 @@ dependencies:
89
89
  version: "0"
90
90
  type: :development
91
91
  version_requirements: *id005
92
+ - !ruby/object:Gem::Dependency
93
+ name: rake
94
+ prerelease: false
95
+ requirement: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ type: :development
105
+ version_requirements: *id006
92
106
  description: Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.
93
107
  email: dbalatero@gmail.com
94
108
  executables: []
@@ -134,6 +148,7 @@ files:
134
148
  - spec/fixtures/result_set.xml
135
149
  - spec/servers/app.rb
136
150
  - spec/spec_helper.rb
151
+ - spec/support/typhoeus_localhost_server.rb
137
152
  - spec/typhoeus/easy_spec.rb
138
153
  - spec/typhoeus/filter_spec.rb
139
154
  - spec/typhoeus/form_spec.rb