typhoeus 0.2.3 → 0.2.4
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.
- data/CHANGELOG.markdown +4 -0
- data/README.textile +5 -0
- data/VERSION +1 -1
- data/lib/typhoeus/easy.rb +5 -1
- data/lib/typhoeus/form.rb +4 -0
- data/spec/servers/app.rb +2 -1
- data/spec/typhoeus/easy_spec.rb +23 -5
- data/typhoeus.gemspec +2 -2
- metadata +4 -4
data/CHANGELOG.markdown
CHANGED
data/README.textile
CHANGED
@@ -59,6 +59,11 @@ request = Typhoeus::Request.new("http://www.pauldix.net",
|
|
59
59
|
# the options are all optional. The default for :method is :get. Timeout is measured in milliseconds.
|
60
60
|
# cache_timeout is measured in seconds.
|
61
61
|
|
62
|
+
# Run the request via Hydra.
|
63
|
+
hydra = Typhoeus::Hydra.new
|
64
|
+
hydra.queue(request)
|
65
|
+
hydra.run
|
66
|
+
|
62
67
|
# the response object will be set after the request is run
|
63
68
|
response = request.response
|
64
69
|
response.code # http status code
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
data/lib/typhoeus/easy.rb
CHANGED
@@ -226,7 +226,11 @@ module Typhoeus
|
|
226
226
|
|
227
227
|
if method == :post
|
228
228
|
@form.process!
|
229
|
-
|
229
|
+
if @form.multipart?
|
230
|
+
set_option(OPTION_VALUES[:CURLOPT_HTTPPOST], @form)
|
231
|
+
else
|
232
|
+
self.post_data = @form.to_s
|
233
|
+
end
|
230
234
|
else
|
231
235
|
self.url = "#{url}?#{@form.to_s}"
|
232
236
|
end
|
data/lib/typhoeus/form.rb
CHANGED
data/spec/servers/app.rb
CHANGED
@@ -10,7 +10,8 @@ post '/file' do
|
|
10
10
|
{
|
11
11
|
'content-type' => params[:file][:type],
|
12
12
|
'filename' => params[:file][:filename],
|
13
|
-
'content' => params[:file][:tempfile].read
|
13
|
+
'content' => params[:file][:tempfile].read,
|
14
|
+
'request-content-type' => request.env['CONTENT_TYPE']
|
14
15
|
}.to_json
|
15
16
|
end
|
16
17
|
|
data/spec/typhoeus/easy_spec.rb
CHANGED
@@ -244,21 +244,39 @@ describe Typhoeus::Easy do
|
|
244
244
|
easy.params = {:foo => "bar"}
|
245
245
|
easy.perform
|
246
246
|
easy.response_code.should == 200
|
247
|
-
easy.response_body.should
|
247
|
+
easy.response_body.should =~ /foo=bar/
|
248
248
|
end
|
249
249
|
|
250
|
-
it "should
|
250
|
+
it "should use Content-Type: application/x-www-form-urlencoded for normal posts" do
|
251
|
+
easy = Typhoeus::Easy.new
|
252
|
+
easy.url = "http://localhost:3002/normal_post"
|
253
|
+
easy.method = :post
|
254
|
+
easy.params = { :a => 'b', :c => 'd',
|
255
|
+
:e => { :f => { :g => 'h' } } }
|
256
|
+
easy.perform
|
257
|
+
|
258
|
+
request = JSON.parse(easy.response_body)
|
259
|
+
request['CONTENT_TYPE'].should == 'application/x-www-form-urlencoded'
|
260
|
+
request['rack.request.form_vars'].should == 'a=b&c=d&e%5Bf%5D%5Bg%5D=h'
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should handle a file upload, as multipart" do
|
251
264
|
easy = Typhoeus::Easy.new
|
252
265
|
easy.url = "http://localhost:3002/file"
|
253
266
|
easy.method = :post
|
254
267
|
easy.params = {:file => File.open(File.expand_path(File.dirname(__FILE__) + "/../fixtures/placeholder.txt"), "r")}
|
255
268
|
easy.perform
|
256
269
|
easy.response_code.should == 200
|
257
|
-
JSON.parse(easy.response_body)
|
258
|
-
|
270
|
+
result = JSON.parse(easy.response_body)
|
271
|
+
|
272
|
+
{ 'content-type' => 'text/plain',
|
259
273
|
'filename' => 'placeholder.txt',
|
260
274
|
'content' => 'This file is used to test uploading.'
|
261
|
-
}
|
275
|
+
}.each do |key, val|
|
276
|
+
result[key].should == val
|
277
|
+
end
|
278
|
+
|
279
|
+
result['request-content-type'].should =~ /multipart/
|
262
280
|
end
|
263
281
|
end
|
264
282
|
|
data/typhoeus.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{typhoeus}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Paul Dix", "David Balatero"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-24}
|
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
14
|
s.email = %q{dbalatero@gmail.com}
|
15
15
|
s.extensions = ["ext/typhoeus/extconf.rb"]
|
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:
|
4
|
+
hash: 31
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 4
|
10
|
+
version: 0.2.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Dix
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-02-
|
19
|
+
date: 2011-02-24 00:00:00 -08:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|