jruby-http-reactor 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -31,6 +31,7 @@ begin
31
31
  gemspec.files.exclude 'docs/**/*'
32
32
  gemspec.files.exclude '.gitignore'
33
33
  end
34
+ Jeweler::GemcutterTasks.new
34
35
  rescue LoadError
35
36
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
36
37
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.2
1
+ 0.5.3
@@ -1,11 +1,11 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{jruby-http-reactor}
8
- s.version = "0.5.2"
8
+ s.version = "0.5.3"
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"]
@@ -53,3 +53,4 @@ Gem::Specification.new do |s|
53
53
  else
54
54
  end
55
55
  end
56
+
@@ -1,5 +1,7 @@
1
1
  module HttpReactor #:nodoc:
2
2
  class RequestExecutionHandler #:nodoc:
3
+ import org.apache.http
4
+ import org.apache.http.message
3
5
  import org.apache.http.protocol
4
6
  import org.apache.http.nio.protocol
5
7
  include HttpRequestExecutionHandler
@@ -36,16 +38,19 @@ module HttpReactor #:nodoc:
36
38
  target_request = context.get_attribute(HTTP_TARGET_REQUEST)
37
39
  flag = context.get_attribute(REQUEST_SENT);
38
40
  if flag.nil?
39
- # Stick some object into the context
40
- context.set_attribute(REQUEST_SENT, true);
41
-
42
- #puts "--------------"
43
- #puts "Sending request to #{target_host}#{target_path}"
44
- #puts "--------------"
41
+ begin
42
+ # Stick some object into the context
43
+ context.set_attribute(REQUEST_SENT, true);
45
44
 
46
- org.apache.http.message.BasicHttpEntityEnclosingRequest.new(
47
- target_request.method, target_path
48
- )
45
+ request = org.apache.http.message.BasicHttpEntityEnclosingRequest.new(
46
+ target_request.method, target_path
47
+ )
48
+ request.headers = target_request.headers.map { |k, v| BasicHeader.new(k, v) }.to_java(Header)
49
+ request
50
+ rescue Exception => e
51
+ puts "Error submitting request: #{e.message}"
52
+ raise e
53
+ end
49
54
  else
50
55
  # No new request to submit
51
56
  end
@@ -12,5 +12,17 @@ module HttpReactor
12
12
  @payload = payload
13
13
  @extra = extra
14
14
  end
15
+
16
+ def [](name)
17
+ headers[name]
18
+ end
19
+
20
+ def []=(name, value)
21
+ headers[name] = value
22
+ end
23
+
24
+ def headers
25
+ @headers ||= Hash.new
26
+ end
15
27
  end
16
28
  end
@@ -35,7 +35,7 @@ class ClientTest < Test::Unit::TestCase
35
35
  assert_equal 200, response.code
36
36
  mime_type = MIME::Types[response.content_type].first
37
37
  assert_equal "text/html", mime_type.content_type
38
- puts "request ur: #{context.getAttribute('http_target_request').uri}"
38
+ puts "request uri: #{context.getAttribute('http_target_request').uri}"
39
39
  puts "content-length: #{response.content_length}"
40
40
  assert response.body.length > 0
41
41
  puts "=== HEADERS ==="
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.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Eden