typhoeus 0.2.4 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +22 -0
- data/Gemfile +1 -9
- data/Gemfile.lock +21 -18
- data/Rakefile +19 -7
- data/ext/typhoeus/typhoeus_multi.c +7 -1
- data/lib/typhoeus.rb +1 -2
- data/lib/typhoeus/easy.rb +25 -5
- data/lib/typhoeus/hydra.rb +5 -1
- data/lib/typhoeus/hydra/stubbing.rb +16 -0
- data/lib/typhoeus/request.rb +32 -4
- data/lib/typhoeus/response.rb +36 -5
- data/lib/typhoeus/utils.rb +5 -4
- data/lib/typhoeus/version.rb +3 -0
- data/spec/servers/app.rb +4 -0
- data/spec/spec_helper.rb +3 -3
- data/spec/typhoeus/easy_spec.rb +46 -10
- data/spec/typhoeus/form_spec.rb +17 -7
- data/spec/typhoeus/hydra_mock_spec.rb +22 -22
- data/spec/typhoeus/hydra_spec.rb +76 -0
- data/spec/typhoeus/request_spec.rb +97 -2
- data/spec/typhoeus/response_spec.rb +41 -0
- data/typhoeus.gemspec +28 -137
- metadata +43 -98
- data/README.textile +0 -372
- data/VERSION +0 -1
- data/benchmarks/profile.rb +0 -25
- data/benchmarks/vs_nethttp.rb +0 -35
- data/examples/file.rb +0 -12
- data/examples/times.rb +0 -40
- data/examples/twitter.rb +0 -21
- data/profilers/valgrind.rb +0 -24
- data/spec/spec.opts +0 -3
data/examples/times.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../lib/typhoeus.rb'
|
2
|
-
|
3
|
-
hydra = Typhoeus::Hydra.new
|
4
|
-
hydra.disable_memoization
|
5
|
-
|
6
|
-
urls = [
|
7
|
-
'http://google.com',
|
8
|
-
'http://testphp.vulnweb.com',
|
9
|
-
'http://demo.testfire.net',
|
10
|
-
'http://example.net',
|
11
|
-
]
|
12
|
-
|
13
|
-
10.times {
|
14
|
-
|i|
|
15
|
-
|
16
|
-
req = Typhoeus::Request.new( urls[ i % urls.size] )
|
17
|
-
req.on_complete {
|
18
|
-
|res|
|
19
|
-
puts 'URL: ' + res.effective_url
|
20
|
-
puts 'Time: ' + res.time.to_s
|
21
|
-
puts 'Connect time: ' + res.connect_time.to_s
|
22
|
-
puts 'App connect time: ' + res.app_connect_time.to_s
|
23
|
-
puts 'Start transfer time: ' + res.start_transfer_time.to_s
|
24
|
-
puts 'Pre transfer time: ' + res.pretransfer_time.to_s
|
25
|
-
puts '-------------'
|
26
|
-
}
|
27
|
-
|
28
|
-
hydra.queue( req )
|
29
|
-
puts 'Queued: ' + req.url
|
30
|
-
}
|
31
|
-
|
32
|
-
puts
|
33
|
-
puts 'Harvesting responses...'
|
34
|
-
puts
|
35
|
-
|
36
|
-
hydra.run
|
37
|
-
|
38
|
-
puts
|
39
|
-
puts 'Done.'
|
40
|
-
puts
|
data/examples/twitter.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require File.dirname(__FILE__) + '/../lib/typhoeus.rb'
|
3
|
-
require 'json'
|
4
|
-
|
5
|
-
class Twitter
|
6
|
-
include Typhoeus
|
7
|
-
remote_defaults :on_success => lambda {|response| JSON.parse(response.body)},
|
8
|
-
:on_failure => lambda {|response| puts "error code: #{response.code}"},
|
9
|
-
:base_uri => "http://search.twitter.com"
|
10
|
-
|
11
|
-
define_remote_method :search, :path => '/search.json'
|
12
|
-
define_remote_method :trends, :path => '/trends/:time_frame.json'
|
13
|
-
end
|
14
|
-
|
15
|
-
tweets = Twitter.search(:params => {:q => "railsconf"})
|
16
|
-
trends = Twitter.trends(:time_frame => :current)
|
17
|
-
|
18
|
-
# and then the calls don't actually happen until the first time you
|
19
|
-
# call a method on one of the objects returned from the remote_method
|
20
|
-
|
21
|
-
puts tweets.keys # it's a hash from parsed JSON
|
data/profilers/valgrind.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# go to ext/typhoeus and run ruby extconf.rb && make before running
|
3
|
-
# this.
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__) + "/../ext")
|
6
|
-
require File.dirname(__FILE__) + "/../lib/typhoeus"
|
7
|
-
|
8
|
-
klass = Class.new { include Typhoeus }
|
9
|
-
|
10
|
-
loops = ENV['LOOPS'].to_i
|
11
|
-
url = ARGV.first || (raise "requires URL!")
|
12
|
-
|
13
|
-
loops.times do |i|
|
14
|
-
puts "On loop #{i}" if i % 10 == 0
|
15
|
-
results = []
|
16
|
-
5.times do
|
17
|
-
results << klass.get(url)
|
18
|
-
end
|
19
|
-
|
20
|
-
# fire requests
|
21
|
-
results[0].code
|
22
|
-
end
|
23
|
-
|
24
|
-
puts "Ran #{loops} loops on #{url}!"
|
data/spec/spec.opts
DELETED