jruby-http-reactor 0.5.3 → 0.5.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.3
1
+ 0.5.4
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env jruby
2
+ #
3
+ # Usage: jruby examples/textfile.rb urls.txt
4
+ #
5
+ # Dependencies:
6
+ #
7
+ # threadify (1.1.0) (optional, uncomment in code)
8
+
9
+ require 'uri'
10
+ require 'rubygems'
11
+ require File.dirname(__FILE__) + '/../lib/http_reactor'
12
+
13
+ def requests
14
+ @requests ||= begin
15
+ puts "Generating requests"
16
+ requests = []
17
+ open(ARGV.pop) do |f|
18
+ f.each do |line|
19
+ requests << HttpReactor::Request.new(URI.parse(line)) if line =~ /^http:/
20
+ end
21
+ end
22
+ puts "Generated #{requests.length} requests"
23
+ requests
24
+ end
25
+ end
26
+
27
+ #uris.threadify(:each_slice, 1) do |slice|
28
+ HttpReactor::Client.new(requests) do |response, context|
29
+ request = context.get_attribute('http_target_request')
30
+ puts "Request URI: #{request.uri}"
31
+ puts "Response: #{response.status_line.status_code}"
32
+ puts "Content length: #{response.body.length}"
33
+ end
34
+ #end
35
+ puts "Processed #{requests.length} feeds"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jruby-http-reactor}
8
- s.version = "0.5.3"
8
+ s.version = "0.5.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Anthony Eden"]
12
- s.date = %q{2009-10-22}
12
+ s.date = %q{2009-11-19}
13
13
  s.description = %q{}
14
14
  s.email = %q{anthonyeden@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -40,7 +40,8 @@ Gem::Specification.new do |s|
40
40
  s.test_files = [
41
41
  "test/client_test.rb",
42
42
  "test/test_helper.rb",
43
- "examples/opml.rb"
43
+ "examples/opml.rb",
44
+ "examples/textfile.rb"
44
45
  ]
45
46
 
46
47
  if s.respond_to? :specification_version then
@@ -68,11 +68,15 @@ module HttpReactor #:nodoc:
68
68
  context.setAttribute(RESPONSE_RECEIVED, true)
69
69
  @request_count.count_down()
70
70
  else
71
- #puts "Redirecting to #{redirect_to}"
71
+
72
+ request = context.getAttribute(HTTP_TARGET_REQUEST)
73
+ request.uri.merge!(URI.parse(redirect_to))
74
+ redirect_to = request.uri
75
+
76
+ puts "Redirecting to #{redirect_to}"
72
77
  redirect_history << redirect_to
73
78
  context.setAttribute(REDIRECT_HISTORY, redirect_history)
74
- request = context.getAttribute(HTTP_TARGET_REQUEST)
75
- request.uri = URI.parse(redirect_to)
79
+
76
80
  io_reactor = context.getAttribute(IO_REACTOR)
77
81
  HttpReactor::Client.process_requests([request], io_reactor, @request_count)
78
82
  end
@@ -84,6 +88,7 @@ module HttpReactor #:nodoc:
84
88
  end
85
89
  rescue => e
86
90
  puts "Error handling response: #{e.message}"
91
+ puts e.backtrace.map{|t| "\t#{t}" }.join("\n")
87
92
  end
88
93
  end
89
94
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-http-reactor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Eden
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-10-22 00:00:00 -10:00
12
+ date: 2009-11-19 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -69,3 +69,4 @@ test_files:
69
69
  - test/client_test.rb
70
70
  - test/test_helper.rb
71
71
  - examples/opml.rb
72
+ - examples/textfile.rb