rack-jetty 0.1.0 → 0.2.0
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/VERSION +1 -1
- data/lib/rack_jetty/servlet_handler.rb +14 -3
- data/spec/images/image.jpg +0 -0
- data/spec/rack_handler_jetty_spec.rb +22 -1
- data/spec/spec_helper.rb +12 -4
- metadata +70 -70
- data/.gitignore +0 -21
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -22,7 +22,7 @@ module RackJetty
|
|
22
22
|
env = DefaultRackEnv.merge({
|
23
23
|
'rack.input' => Rack::RewindableInput.new(JavaInput.new(request.get_input_stream)),
|
24
24
|
'rack.url_scheme' => request.get_scheme,
|
25
|
-
'CONTENT_TYPE' => request.get_content_type
|
25
|
+
'CONTENT_TYPE' => request.get_content_type,
|
26
26
|
'CONTENT_LENGTH' => request.get_content_length, # some post-processing done below
|
27
27
|
'REQUEST_METHOD' => request.get_method || "GET",
|
28
28
|
'REQUEST_URI' => request.getRequestURI,
|
@@ -41,6 +41,17 @@ module RackJetty
|
|
41
41
|
env[k] = request.getHeader(h) unless env.has_key?(k)
|
42
42
|
end
|
43
43
|
|
44
|
+
# request.get_content_type returns nil if the Content-Type is not included
|
45
|
+
# and Rack doesn't expect Content-Type => '' - certain methods will issue
|
46
|
+
# a backtrace if it's passed in.
|
47
|
+
#
|
48
|
+
# The correct behaviour is not to include Content-Type in the env hash
|
49
|
+
# if it is blank.
|
50
|
+
#
|
51
|
+
# https://github.com/rack/rack/issues#issue/40 covers the problem from
|
52
|
+
# Rack's end.
|
53
|
+
env.delete('CONTENT_TYPE') if [nil, ''].include?(env['CONTENT_TYPE'])
|
54
|
+
|
44
55
|
status, headers, output = handler.app.call(env)
|
45
56
|
|
46
57
|
if (match = %r{^([0-9]{3,3}) +([[:print:]]+)$}.match(status.to_s))
|
@@ -62,11 +73,11 @@ module RackJetty
|
|
62
73
|
|
63
74
|
buffer = response.get_output_stream
|
64
75
|
output.each do |s|
|
65
|
-
buffer.
|
76
|
+
buffer.write(s.to_java_bytes)
|
66
77
|
end
|
67
78
|
ensure
|
68
79
|
request.set_handled(true)
|
69
80
|
end
|
70
81
|
end
|
71
82
|
end
|
72
|
-
end
|
83
|
+
end
|
Binary file
|
@@ -1,12 +1,20 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
require 'rack/handler/jetty'
|
3
3
|
require 'rack/lint'
|
4
|
+
require 'rack/builder'
|
5
|
+
require 'rack/static'
|
4
6
|
|
5
7
|
describe Rack::Handler::Jetty do
|
6
8
|
include TestRequest::Helpers
|
7
9
|
|
8
10
|
before :all do
|
9
|
-
|
11
|
+
app = Rack::Builder.app do
|
12
|
+
use Rack::Lint
|
13
|
+
use Rack::Static, :urls => ["/spec/images"]
|
14
|
+
run TestRequest.new
|
15
|
+
end
|
16
|
+
|
17
|
+
@server = Rack::Handler::Jetty.new(app, :Host => @host='0.0.0.0',:Port => @port=9204)
|
10
18
|
Thread.new do
|
11
19
|
@server.run
|
12
20
|
end
|
@@ -59,4 +67,17 @@ describe Rack::Handler::Jetty do
|
|
59
67
|
status.should == 403
|
60
68
|
response["rack.url_scheme"].should == "http"
|
61
69
|
end
|
70
|
+
|
71
|
+
it "should not set content-type to '' in requests" do
|
72
|
+
GET("/test", 'Content-Type' => '')
|
73
|
+
response['Content-Type'].should == nil
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should serve images" do
|
77
|
+
file_size = File.size(File.join(File.dirname(__FILE__), 'images', 'image.jpg'))
|
78
|
+
GET("/spec/images/image.jpg")
|
79
|
+
status.should == 200
|
80
|
+
response.content_length.should == file_size
|
81
|
+
response.body.size.should == file_size
|
82
|
+
end
|
62
83
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -43,10 +43,10 @@ class TestRequest
|
|
43
43
|
get.basic_auth user, passwd if user && passwd
|
44
44
|
http.request(get) { |response|
|
45
45
|
@status = response.code.to_i
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
@response =
|
46
|
+
if response.content_type == "text/yaml"
|
47
|
+
load_yaml(response)
|
48
|
+
else
|
49
|
+
@response = response
|
50
50
|
end
|
51
51
|
}
|
52
52
|
}
|
@@ -66,5 +66,13 @@ class TestRequest
|
|
66
66
|
}
|
67
67
|
}
|
68
68
|
end
|
69
|
+
|
70
|
+
def load_yaml(response)
|
71
|
+
begin
|
72
|
+
@response = YAML.load(response.body)
|
73
|
+
rescue ArgumentError
|
74
|
+
@response = nil
|
75
|
+
end
|
76
|
+
end
|
69
77
|
end
|
70
78
|
end
|
metadata
CHANGED
@@ -3,48 +3,48 @@ name: rack-jetty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
version: 0.
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
|
-
- Graham Batty
|
12
|
+
- Graham Batty
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-11-24 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
- !ruby/object:Gem::Dependency
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 1
|
29
|
+
- 2
|
30
|
+
- 9
|
31
|
+
version: 1.2.9
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: rack
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 1
|
43
|
+
- 0
|
44
|
+
- 0
|
45
|
+
version: 1.0.0
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
48
|
description: Allows you to use Jetty as a Rack adapter in JRuby. Compatible with rackup and rails' Rack support.
|
49
49
|
email: graham@stormbrew.ca
|
50
50
|
executables: []
|
@@ -52,51 +52,51 @@ executables: []
|
|
52
52
|
extensions: []
|
53
53
|
|
54
54
|
extra_rdoc_files:
|
55
|
-
- LICENSE
|
56
|
-
- README.rdoc
|
55
|
+
- LICENSE
|
56
|
+
- README.rdoc
|
57
57
|
files:
|
58
|
-
- .document
|
59
|
-
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
- lib/
|
65
|
-
- lib/rack_jetty/jars/
|
66
|
-
- lib/rack_jetty/jars/jetty-6.1.14.jar
|
67
|
-
- lib/rack_jetty/jars/jetty-
|
68
|
-
- lib/rack_jetty/jars/
|
69
|
-
- lib/rack_jetty/jars/jsp-2.1.jar
|
70
|
-
- lib/rack_jetty/jars/
|
71
|
-
- lib/rack_jetty/
|
72
|
-
- lib/rack_jetty/
|
73
|
-
-
|
74
|
-
- spec/rack_handler_jetty_spec.rb
|
75
|
-
- spec/spec.opts
|
76
|
-
- spec/spec_helper.rb
|
58
|
+
- .document
|
59
|
+
- LICENSE
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- VERSION
|
63
|
+
- lib/rack/handler/jetty.rb
|
64
|
+
- lib/rack_jetty/jars/core-3.1.1.jar
|
65
|
+
- lib/rack_jetty/jars/jetty-6.1.14.jar
|
66
|
+
- lib/rack_jetty/jars/jetty-plus-6.1.14.jar
|
67
|
+
- lib/rack_jetty/jars/jetty-util-6.1.14.jar
|
68
|
+
- lib/rack_jetty/jars/jsp-2.1.jar
|
69
|
+
- lib/rack_jetty/jars/jsp-api-2.1.jar
|
70
|
+
- lib/rack_jetty/jars/servlet-api-2.5-6.1.14.jar
|
71
|
+
- lib/rack_jetty/java_input.rb
|
72
|
+
- lib/rack_jetty/servlet_handler.rb
|
73
|
+
- spec/images/image.jpg
|
74
|
+
- spec/rack_handler_jetty_spec.rb
|
75
|
+
- spec/spec.opts
|
76
|
+
- spec/spec_helper.rb
|
77
77
|
has_rdoc: true
|
78
78
|
homepage: http://github.com/stormbrew/rack-jetty
|
79
79
|
licenses: []
|
80
80
|
|
81
81
|
post_install_message:
|
82
|
-
rdoc_options:
|
83
|
-
|
82
|
+
rdoc_options: []
|
83
|
+
|
84
84
|
require_paths:
|
85
|
-
- lib
|
85
|
+
- lib
|
86
86
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
segments:
|
91
|
+
- 0
|
92
|
+
version: "0"
|
93
93
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
100
|
requirements: []
|
101
101
|
|
102
102
|
rubyforge_project:
|
@@ -105,5 +105,5 @@ signing_key:
|
|
105
105
|
specification_version: 3
|
106
106
|
summary: Very simple (mostly Ruby) implementation of jetty as a pure Rack adapter.
|
107
107
|
test_files:
|
108
|
-
- spec/rack_handler_jetty_spec.rb
|
109
|
-
- spec/spec_helper.rb
|
108
|
+
- spec/rack_handler_jetty_spec.rb
|
109
|
+
- spec/spec_helper.rb
|