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 +1 -0
- data/VERSION +1 -1
- data/jruby-http-reactor.gemspec +4 -3
- data/lib/http_reactor/client.rb +14 -9
- data/lib/http_reactor/request.rb +12 -0
- data/test/client_test.rb +1 -1
- metadata +1 -1
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.
|
1
|
+
0.5.3
|
data/jruby-http-reactor.gemspec
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
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.
|
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
|
+
|
data/lib/http_reactor/client.rb
CHANGED
@@ -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
|
-
|
40
|
-
|
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
|
-
|
47
|
-
|
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
|
data/lib/http_reactor/request.rb
CHANGED
data/test/client_test.rb
CHANGED
@@ -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
|
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 ==="
|