parallel_http 0.0.14 → 0.0.15

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.
Files changed (2) hide show
  1. data/lib/parallel_http.rb +10 -3
  2. metadata +1 -1
data/lib/parallel_http.rb CHANGED
@@ -25,7 +25,7 @@ class ParallelHttp
25
25
  body = result.response.force_encoding('UTF-8').encode('UTF-16', :invalid => :replace, :replace => '').encode('UTF-8')
26
26
  end
27
27
  hsh = {:id => id, :response_code => result.response_header.status, :body => body}
28
- hsh.merge!(:error => error.map{|e| e.inspect}.join(', ')) if error
28
+ hsh.merge!(:error => error) if error
29
29
  @@results << hsh
30
30
  if @@request_size == @@results.size
31
31
  EM.stop
@@ -37,10 +37,17 @@ class ParallelHttp
37
37
  opts = request[:options] || {}
38
38
  http = EventMachine::HttpRequest.new(request[:url], options).send(request[:verb].downcase, opts)
39
39
  http.callback do
40
+ @@success = request[:options][:query][:url]
41
+ # puts "SUCCESS: #{request[:options][:query][:url]}"
40
42
  ParallelHttp.exec_result(request[:id], http)
43
+ http.close(nil)
41
44
  end
42
- http.errback do |error|
43
- ParallelHttp.exec_result(request[:id], http, http.error)
45
+ http.errback do |h|
46
+ if request[:options][:query][:url] != @@success
47
+ # puts "FAILURE: #{request[:options][:query][:url]}"
48
+ ParallelHttp.exec_result(request[:id], h, h.error)
49
+ http.close(nil)
50
+ end
44
51
  end
45
52
  end
46
53
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: