typhoeus 0.1.24 → 0.1.25
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +289 -0
- data/Rakefile +33 -0
- data/VERSION +1 -0
- data/benchmarks/profile.rb +25 -0
- data/benchmarks/vs_nethttp.rb +35 -0
- data/examples/twitter.rb +21 -0
- data/lib/typhoeus/easy.rb +11 -1
- data/lib/typhoeus/hydra.rb +11 -1
- data/lib/typhoeus/request.rb +1 -1
- data/lib/typhoeus/response.rb +8 -6
- data/lib/typhoeus/service.rb +20 -0
- data/profilers/valgrind.rb +24 -0
- data/spec/fixtures/result_set.xml +60 -0
- data/spec/typhoeus/easy_spec.rb +17 -1
- data/spec/typhoeus/hydra_spec.rb +311 -0
- data/spec/typhoeus/request_spec.rb +169 -0
- data/typhoeus.gemspec +94 -0
- metadata +49 -40
@@ -0,0 +1,169 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Typhoeus::Request do
|
4
|
+
describe "#params_string" do
|
5
|
+
it "should dump a sorted string" do
|
6
|
+
request = Typhoeus::Request.new(
|
7
|
+
"http://google.com",
|
8
|
+
:params => {
|
9
|
+
'b' => 'fdsa',
|
10
|
+
'a' => 'jlk',
|
11
|
+
'c' => '789'
|
12
|
+
}
|
13
|
+
)
|
14
|
+
|
15
|
+
request.params_string.should == "a=jlk&b=fdsa&c=789"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should accept symboled keys" do
|
19
|
+
request = Typhoeus::Request.new('http://google.com',
|
20
|
+
:params => {
|
21
|
+
:b => 'fdsa',
|
22
|
+
:a => 'jlk',
|
23
|
+
:c => '789'
|
24
|
+
})
|
25
|
+
request.params_string.should == "a=jlk&b=fdsa&c=789"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "quick request methods" do
|
30
|
+
it "can run a GET synchronously" do
|
31
|
+
response = Typhoeus::Request.get("http://localhost:3000", :params => {:q => "hi"}, :headers => {:foo => "bar"})
|
32
|
+
response.code.should == 200
|
33
|
+
JSON.parse(response.body)["REQUEST_METHOD"].should == "GET"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "can run a POST synchronously" do
|
37
|
+
response = Typhoeus::Request.post("http://localhost:3000", :params => {:q => "hi"}, :headers => {:foo => "bar"})
|
38
|
+
response.code.should == 200
|
39
|
+
json = JSON.parse(response.body)
|
40
|
+
json["REQUEST_METHOD"].should == "POST"
|
41
|
+
json["rack.request.query_hash"]["q"].should == "hi"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "can run a PUT synchronously" do
|
45
|
+
response = Typhoeus::Request.put("http://localhost:3000", :params => {:q => "hi"}, :headers => {:foo => "bar"})
|
46
|
+
response.code.should == 200
|
47
|
+
JSON.parse(response.body)["REQUEST_METHOD"].should == "PUT"
|
48
|
+
end
|
49
|
+
|
50
|
+
it "can run a DELETE synchronously" do
|
51
|
+
response = Typhoeus::Request.delete("http://localhost:3000", :params => {:q => "hi"}, :headers => {:foo => "bar"})
|
52
|
+
response.code.should == 200
|
53
|
+
JSON.parse(response.body)["REQUEST_METHOD"].should == "DELETE"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
it "takes url as the first argument" do
|
58
|
+
Typhoeus::Request.new("http://localhost:3000").url.should == "http://localhost:3000"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should parse the host from the url" do
|
62
|
+
Typhoeus::Request.new("http://localhost:3000/whatever?hi=foo").host.should == "http://localhost:3000"
|
63
|
+
Typhoeus::Request.new("http://localhost:3000?hi=foo").host.should == "http://localhost:3000"
|
64
|
+
Typhoeus::Request.new("http://localhost:3000").host.should == "http://localhost:3000"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "takes method as an option" do
|
68
|
+
Typhoeus::Request.new("http://localhost:3000", :method => :get).method.should == :get
|
69
|
+
end
|
70
|
+
|
71
|
+
it "takes headers as an option" do
|
72
|
+
headers = {:foo => :bar}
|
73
|
+
request = Typhoeus::Request.new("http://localhost:3000", :headers => headers)
|
74
|
+
request.headers.should == headers
|
75
|
+
end
|
76
|
+
|
77
|
+
it "takes params as an option and adds them to the url" do
|
78
|
+
Typhoeus::Request.new("http://localhost:3000", :params => {:foo => "bar"}).url.should == "http://localhost:3000?foo=bar"
|
79
|
+
end
|
80
|
+
|
81
|
+
it "takes request body as an option" do
|
82
|
+
Typhoeus::Request.new("http://localhost:3000", :body => "whatever").body.should == "whatever"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "takes timeout as an option" do
|
86
|
+
Typhoeus::Request.new("http://localhost:3000", :timeout => 10).timeout.should == 10
|
87
|
+
end
|
88
|
+
|
89
|
+
it "takes cache_timeout as an option" do
|
90
|
+
Typhoeus::Request.new("http://localhost:3000", :cache_timeout => 60).cache_timeout.should == 60
|
91
|
+
end
|
92
|
+
|
93
|
+
it "takes follow_location as an option" do
|
94
|
+
Typhoeus::Request.new("http://localhost:3000", :follow_location => true).follow_location.should == true
|
95
|
+
end
|
96
|
+
|
97
|
+
it "takes max_redirects as an option" do
|
98
|
+
Typhoeus::Request.new("http://localhost:3000", :max_redirects => 10).max_redirects.should == 10
|
99
|
+
end
|
100
|
+
|
101
|
+
it "has the associated response object" do
|
102
|
+
request = Typhoeus::Request.new("http://localhost:3000")
|
103
|
+
request.response = :foo
|
104
|
+
request.response.should == :foo
|
105
|
+
end
|
106
|
+
|
107
|
+
it "has an on_complete handler that is called when the request is completed" do
|
108
|
+
request = Typhoeus::Request.new("http://localhost:3000")
|
109
|
+
foo = nil
|
110
|
+
request.on_complete do |response|
|
111
|
+
foo = response
|
112
|
+
end
|
113
|
+
request.response = :bar
|
114
|
+
request.call_handlers
|
115
|
+
foo.should == :bar
|
116
|
+
end
|
117
|
+
|
118
|
+
it "has an on_complete setter" do
|
119
|
+
foo = nil
|
120
|
+
proc = Proc.new {|response| foo = response}
|
121
|
+
request = Typhoeus::Request.new("http://localhost:3000")
|
122
|
+
request.on_complete = proc
|
123
|
+
request.response = :bar
|
124
|
+
request.call_handlers
|
125
|
+
foo.should == :bar
|
126
|
+
end
|
127
|
+
|
128
|
+
it "stores the handled response that is the return value from the on_complete block" do
|
129
|
+
request = Typhoeus::Request.new("http://localhost:3000")
|
130
|
+
request.on_complete do |response|
|
131
|
+
"handled"
|
132
|
+
end
|
133
|
+
request.response = :bar
|
134
|
+
request.call_handlers
|
135
|
+
request.handled_response.should == "handled"
|
136
|
+
end
|
137
|
+
|
138
|
+
it "has an after_complete handler that recieves what on_complete returns" do
|
139
|
+
request = Typhoeus::Request.new("http://localhost:3000")
|
140
|
+
request.on_complete do |response|
|
141
|
+
"handled"
|
142
|
+
end
|
143
|
+
good = nil
|
144
|
+
request.after_complete do |object|
|
145
|
+
good = object == "handled"
|
146
|
+
end
|
147
|
+
request.call_handlers
|
148
|
+
good.should be_true
|
149
|
+
end
|
150
|
+
|
151
|
+
it "has an after_complete setter" do
|
152
|
+
request = Typhoeus::Request.new("http://localhost:3000")
|
153
|
+
request.on_complete do |response|
|
154
|
+
"handled"
|
155
|
+
end
|
156
|
+
good = nil
|
157
|
+
proc = Proc.new {|object| good = object == "handled"}
|
158
|
+
request.after_complete = proc
|
159
|
+
|
160
|
+
request.call_handlers
|
161
|
+
good.should be_true
|
162
|
+
end
|
163
|
+
|
164
|
+
describe "retry" do
|
165
|
+
it "should take a retry option"
|
166
|
+
it "should count the number of times a request has failed"
|
167
|
+
end
|
168
|
+
|
169
|
+
end
|
data/typhoeus.gemspec
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{typhoeus}
|
8
|
+
s.version = "0.1.25"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Paul Dix"]
|
12
|
+
s.date = %q{2010-05-13}
|
13
|
+
s.description = %q{Like a modern code version of the mythical beast with 100 serpent heads, Typhoeus runs HTTP requests in parallel while cleanly encapsulating handling logic.}
|
14
|
+
s.email = %q{paul@pauldix.net}
|
15
|
+
s.extensions = ["ext/typhoeus/extconf.rb"]
|
16
|
+
s.extra_rdoc_files = [
|
17
|
+
"README.textile"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".gitignore",
|
21
|
+
"README.textile",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"benchmarks/profile.rb",
|
25
|
+
"benchmarks/vs_nethttp.rb",
|
26
|
+
"examples/twitter.rb",
|
27
|
+
"ext/typhoeus/.gitignore",
|
28
|
+
"ext/typhoeus/Makefile",
|
29
|
+
"ext/typhoeus/extconf.rb",
|
30
|
+
"ext/typhoeus/native.c",
|
31
|
+
"ext/typhoeus/native.h",
|
32
|
+
"ext/typhoeus/typhoeus_easy.c",
|
33
|
+
"ext/typhoeus/typhoeus_easy.h",
|
34
|
+
"ext/typhoeus/typhoeus_multi.c",
|
35
|
+
"ext/typhoeus/typhoeus_multi.h",
|
36
|
+
"lib/typhoeus.rb",
|
37
|
+
"lib/typhoeus/.gitignore",
|
38
|
+
"lib/typhoeus/easy.rb",
|
39
|
+
"lib/typhoeus/filter.rb",
|
40
|
+
"lib/typhoeus/hydra.rb",
|
41
|
+
"lib/typhoeus/multi.rb",
|
42
|
+
"lib/typhoeus/remote.rb",
|
43
|
+
"lib/typhoeus/remote_method.rb",
|
44
|
+
"lib/typhoeus/remote_proxy_object.rb",
|
45
|
+
"lib/typhoeus/request.rb",
|
46
|
+
"lib/typhoeus/response.rb",
|
47
|
+
"lib/typhoeus/service.rb",
|
48
|
+
"profilers/valgrind.rb",
|
49
|
+
"spec/fixtures/result_set.xml",
|
50
|
+
"spec/servers/app.rb",
|
51
|
+
"spec/spec.opts",
|
52
|
+
"spec/spec_helper.rb",
|
53
|
+
"spec/typhoeus/easy_spec.rb",
|
54
|
+
"spec/typhoeus/filter_spec.rb",
|
55
|
+
"spec/typhoeus/hydra_spec.rb",
|
56
|
+
"spec/typhoeus/multi_spec.rb",
|
57
|
+
"spec/typhoeus/remote_method_spec.rb",
|
58
|
+
"spec/typhoeus/remote_proxy_object_spec.rb",
|
59
|
+
"spec/typhoeus/remote_spec.rb",
|
60
|
+
"spec/typhoeus/request_spec.rb",
|
61
|
+
"spec/typhoeus/response_spec.rb",
|
62
|
+
"typhoeus.gemspec"
|
63
|
+
]
|
64
|
+
s.homepage = %q{http://github.com/pauldix/typhoeus}
|
65
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
66
|
+
s.require_paths = ["lib"]
|
67
|
+
s.rubygems_version = %q{1.3.6}
|
68
|
+
s.summary = %q{A library for interacting with web services (and building SOAs) at blinding speed.}
|
69
|
+
s.test_files = [
|
70
|
+
"spec/servers/app.rb",
|
71
|
+
"spec/spec_helper.rb",
|
72
|
+
"spec/typhoeus/easy_spec.rb",
|
73
|
+
"spec/typhoeus/filter_spec.rb",
|
74
|
+
"spec/typhoeus/hydra_spec.rb",
|
75
|
+
"spec/typhoeus/multi_spec.rb",
|
76
|
+
"spec/typhoeus/remote_method_spec.rb",
|
77
|
+
"spec/typhoeus/remote_proxy_object_spec.rb",
|
78
|
+
"spec/typhoeus/remote_spec.rb",
|
79
|
+
"spec/typhoeus/request_spec.rb",
|
80
|
+
"spec/typhoeus/response_spec.rb",
|
81
|
+
"examples/twitter.rb"
|
82
|
+
]
|
83
|
+
|
84
|
+
if s.respond_to? :specification_version then
|
85
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
86
|
+
s.specification_version = 3
|
87
|
+
|
88
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
89
|
+
else
|
90
|
+
end
|
91
|
+
else
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 25
|
9
|
+
version: 0.1.25
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Paul Dix
|
@@ -14,73 +14,71 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2010-05-13 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
|
-
dependencies:
|
20
|
-
|
21
|
-
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - ">"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
segments:
|
28
|
-
- 0
|
29
|
-
- 9
|
30
|
-
- 0
|
31
|
-
version: 0.9.0
|
32
|
-
type: :runtime
|
33
|
-
version_requirements: *id001
|
34
|
-
description:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
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.
|
35
22
|
email: paul@pauldix.net
|
36
23
|
executables: []
|
37
24
|
|
38
25
|
extensions:
|
39
26
|
- ext/typhoeus/extconf.rb
|
40
|
-
extra_rdoc_files:
|
41
|
-
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.textile
|
42
29
|
files:
|
43
30
|
- .gitignore
|
31
|
+
- README.textile
|
32
|
+
- Rakefile
|
33
|
+
- VERSION
|
34
|
+
- benchmarks/profile.rb
|
35
|
+
- benchmarks/vs_nethttp.rb
|
36
|
+
- examples/twitter.rb
|
44
37
|
- ext/typhoeus/.gitignore
|
38
|
+
- ext/typhoeus/Makefile
|
45
39
|
- ext/typhoeus/extconf.rb
|
46
|
-
- ext/typhoeus/
|
40
|
+
- ext/typhoeus/native.c
|
41
|
+
- ext/typhoeus/native.h
|
47
42
|
- ext/typhoeus/typhoeus_easy.c
|
48
|
-
- ext/typhoeus/
|
43
|
+
- ext/typhoeus/typhoeus_easy.h
|
49
44
|
- ext/typhoeus/typhoeus_multi.c
|
50
|
-
- ext/typhoeus/
|
51
|
-
- ext/typhoeus/native.h
|
52
|
-
- ext/typhoeus/native.c
|
45
|
+
- ext/typhoeus/typhoeus_multi.h
|
53
46
|
- lib/typhoeus.rb
|
54
47
|
- lib/typhoeus/.gitignore
|
55
48
|
- lib/typhoeus/easy.rb
|
49
|
+
- lib/typhoeus/filter.rb
|
50
|
+
- lib/typhoeus/hydra.rb
|
56
51
|
- lib/typhoeus/multi.rb
|
57
52
|
- lib/typhoeus/remote.rb
|
58
|
-
- lib/typhoeus/remote_proxy_object.rb
|
59
|
-
- lib/typhoeus/filter.rb
|
60
53
|
- lib/typhoeus/remote_method.rb
|
61
|
-
- lib/typhoeus/
|
62
|
-
- lib/typhoeus/hydra.rb
|
54
|
+
- lib/typhoeus/remote_proxy_object.rb
|
63
55
|
- lib/typhoeus/request.rb
|
56
|
+
- lib/typhoeus/response.rb
|
57
|
+
- lib/typhoeus/service.rb
|
58
|
+
- profilers/valgrind.rb
|
59
|
+
- spec/fixtures/result_set.xml
|
60
|
+
- spec/servers/app.rb
|
64
61
|
- spec/spec.opts
|
65
62
|
- spec/spec_helper.rb
|
66
63
|
- spec/typhoeus/easy_spec.rb
|
67
|
-
- spec/typhoeus/multi_spec.rb
|
68
|
-
- spec/typhoeus/remote_spec.rb
|
69
|
-
- spec/typhoeus/remote_proxy_object_spec.rb
|
70
64
|
- spec/typhoeus/filter_spec.rb
|
65
|
+
- spec/typhoeus/hydra_spec.rb
|
66
|
+
- spec/typhoeus/multi_spec.rb
|
71
67
|
- spec/typhoeus/remote_method_spec.rb
|
68
|
+
- spec/typhoeus/remote_proxy_object_spec.rb
|
69
|
+
- spec/typhoeus/remote_spec.rb
|
70
|
+
- spec/typhoeus/request_spec.rb
|
72
71
|
- spec/typhoeus/response_spec.rb
|
73
|
-
-
|
72
|
+
- typhoeus.gemspec
|
74
73
|
has_rdoc: true
|
75
74
|
homepage: http://github.com/pauldix/typhoeus
|
76
75
|
licenses: []
|
77
76
|
|
78
77
|
post_install_message:
|
79
|
-
rdoc_options:
|
80
|
-
|
78
|
+
rdoc_options:
|
79
|
+
- --charset=UTF-8
|
81
80
|
require_paths:
|
82
81
|
- lib
|
83
|
-
- ext
|
84
82
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
83
|
requirements:
|
86
84
|
- - ">="
|
@@ -100,7 +98,18 @@ requirements: []
|
|
100
98
|
rubyforge_project:
|
101
99
|
rubygems_version: 1.3.6
|
102
100
|
signing_key:
|
103
|
-
specification_version:
|
101
|
+
specification_version: 3
|
104
102
|
summary: A library for interacting with web services (and building SOAs) at blinding speed.
|
105
|
-
test_files:
|
106
|
-
|
103
|
+
test_files:
|
104
|
+
- spec/servers/app.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
- spec/typhoeus/easy_spec.rb
|
107
|
+
- spec/typhoeus/filter_spec.rb
|
108
|
+
- spec/typhoeus/hydra_spec.rb
|
109
|
+
- spec/typhoeus/multi_spec.rb
|
110
|
+
- spec/typhoeus/remote_method_spec.rb
|
111
|
+
- spec/typhoeus/remote_proxy_object_spec.rb
|
112
|
+
- spec/typhoeus/remote_spec.rb
|
113
|
+
- spec/typhoeus/request_spec.rb
|
114
|
+
- spec/typhoeus/response_spec.rb
|
115
|
+
- examples/twitter.rb
|