mizuno 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/lib/mizuno/rack/chunked.rb +16 -0
- data/lib/mizuno/{rack_servlet.rb → rack_handler.rb} +19 -18
- data/lib/mizuno/reloader.rb +1 -1
- data/lib/mizuno/server.rb +6 -14
- data/lib/mizuno/version.rb +1 -1
- metadata +121 -50
data/.gitignore
CHANGED
data/lib/mizuno/rack/chunked.rb
CHANGED
@@ -8,6 +8,22 @@ module Rack
|
|
8
8
|
class Chunked
|
9
9
|
include Rack::Utils
|
10
10
|
|
11
|
+
class Body
|
12
|
+
include Rack::Utils
|
13
|
+
|
14
|
+
def initialize(body)
|
15
|
+
@body = body
|
16
|
+
end
|
17
|
+
|
18
|
+
def each(&block)
|
19
|
+
@body.each(&block)
|
20
|
+
end
|
21
|
+
|
22
|
+
def close
|
23
|
+
@body.close if @body.respond_to?(:close)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
11
27
|
def initialize(app)
|
12
28
|
@app = app
|
13
29
|
end
|
@@ -2,18 +2,12 @@ require 'stringio'
|
|
2
2
|
require 'rack/response'
|
3
3
|
|
4
4
|
#
|
5
|
-
# Wraps a Rack application in a
|
6
|
-
#
|
7
|
-
# Relevant documentation:
|
8
|
-
#
|
9
|
-
# http://rack.rubyforge.org/doc/SPEC.html
|
10
|
-
# http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax
|
11
|
-
# /servlet/http/HttpServlet.html
|
5
|
+
# Wraps a Rack application in a Jetty handler.
|
12
6
|
#
|
13
7
|
module Mizuno
|
14
|
-
java_import '
|
8
|
+
java_import 'org.eclipse.jetty.server.handler.AbstractHandler'
|
15
9
|
|
16
|
-
class
|
10
|
+
class RackHandler < AbstractHandler
|
17
11
|
java_import 'java.io.FileInputStream'
|
18
12
|
java_import 'org.eclipse.jetty.continuation.ContinuationSupport'
|
19
13
|
java_import 'org.jruby.rack.servlet.RewindableInputStream'
|
@@ -28,18 +22,22 @@ module Mizuno
|
|
28
22
|
|
29
23
|
#
|
30
24
|
# Sets the Rack application that handles requests sent to this
|
31
|
-
#
|
25
|
+
# Jetty handler.
|
32
26
|
#
|
33
27
|
def rackup(app)
|
34
28
|
@app = app
|
35
29
|
end
|
36
30
|
|
31
|
+
java_signature %{@Override void handle(String target,
|
32
|
+
Request baseRequest, HttpServletRequest request,
|
33
|
+
HttpServletResponse response) throws IOException, ServletException}
|
34
|
+
|
37
35
|
#
|
38
|
-
# Takes an incoming request (as a
|
39
|
-
# the rack application setup via [rackup].
|
40
|
-
# is translating the various bits of the Servlet API into
|
41
|
-
# API on the way in, and translating the response back on
|
42
|
-
# out.
|
36
|
+
# Takes an incoming request (as a HttpServletRequest) and dispatches
|
37
|
+
# it to the rack application setup via [rackup]. All this really
|
38
|
+
# involves is translating the various bits of the Servlet API into
|
39
|
+
# the Rack API on the way in, and translating the response back on
|
40
|
+
# the way out.
|
43
41
|
#
|
44
42
|
# Also, we implement a common extension to the Rack api for
|
45
43
|
# asynchronous request processing. We supply an 'async.callback'
|
@@ -49,7 +47,7 @@ module Mizuno
|
|
49
47
|
# When 'async.callback' gets a response with empty headers and an
|
50
48
|
# empty body, we declare the async response finished.
|
51
49
|
#
|
52
|
-
def
|
50
|
+
def handle(target, base_request, request, response)
|
53
51
|
handle_exceptions(response) do
|
54
52
|
# Turn the ServletRequest into a Rack env hash
|
55
53
|
env = servlet_to_rack(request)
|
@@ -144,7 +142,7 @@ module Mizuno
|
|
144
142
|
|
145
143
|
# Populate the HTTP headers.
|
146
144
|
request.getHeaderNames.each do |header_name|
|
147
|
-
header = header_name.upcase.tr('-', '_')
|
145
|
+
header = header_name.to_s.upcase.tr('-', '_')
|
148
146
|
env["HTTP_#{header}"] = request.getHeader(header_name)
|
149
147
|
end
|
150
148
|
|
@@ -229,7 +227,10 @@ module Mizuno
|
|
229
227
|
end
|
230
228
|
input_stream.close
|
231
229
|
else
|
232
|
-
body.each
|
230
|
+
body.each do |chunk|
|
231
|
+
output.write(chunk.to_java_bytes)
|
232
|
+
output.flush
|
233
|
+
end
|
233
234
|
end
|
234
235
|
|
235
236
|
# Close the body if we're supposed to.
|
data/lib/mizuno/reloader.rb
CHANGED
data/lib/mizuno/server.rb
CHANGED
@@ -4,18 +4,16 @@
|
|
4
4
|
require 'rack'
|
5
5
|
require 'mizuno'
|
6
6
|
Mizuno.require_jars(%w(jetty-continuation jetty-http jetty-io jetty-jmx
|
7
|
-
jetty-security jetty-server jetty-servlet
|
8
|
-
|
7
|
+
jetty-security jetty-server jetty-util servlet-api
|
8
|
+
rewindable-input-stream))
|
9
9
|
require 'mizuno/version'
|
10
10
|
require 'mizuno/rack/chunked'
|
11
|
-
require 'mizuno/
|
11
|
+
require 'mizuno/rack_handler'
|
12
12
|
require 'mizuno/logger'
|
13
13
|
require 'mizuno/reloader'
|
14
14
|
|
15
15
|
module Mizuno
|
16
16
|
class Server
|
17
|
-
java_import 'org.eclipse.jetty.servlet.ServletContextHandler'
|
18
|
-
java_import 'org.eclipse.jetty.servlet.ServletHolder'
|
19
17
|
java_import 'org.eclipse.jetty.server.nio.SelectChannelConnector'
|
20
18
|
java_import 'org.eclipse.jetty.util.thread.QueuedThreadPool'
|
21
19
|
|
@@ -85,23 +83,17 @@ module Mizuno
|
|
85
83
|
Runner.setgid(options) if options[:group]
|
86
84
|
Runner.setuid(options) if options[:user]
|
87
85
|
|
88
|
-
# Servlet handler.
|
89
|
-
app_handler = ServletContextHandler.new(nil, "/",
|
90
|
-
ServletContextHandler::NO_SESSIONS)
|
91
|
-
|
92
86
|
# Optionally wrap with Mizuno::Reloader.
|
93
87
|
threshold = (ENV['RACK_ENV'] == 'production' ? 10 : 1)
|
94
88
|
app = Mizuno::Reloader.new(app, threshold) \
|
95
89
|
if options[:reloadable]
|
96
90
|
|
97
91
|
# The servlet itself.
|
98
|
-
|
99
|
-
|
100
|
-
holder = ServletHolder.new(rack_servlet)
|
101
|
-
app_handler.addServlet(holder, "/")
|
92
|
+
rack_handler = RackHandler.new(self)
|
93
|
+
rack_handler.rackup(app)
|
102
94
|
|
103
95
|
# Add the context to the server and start.
|
104
|
-
@server.set_handler(
|
96
|
+
@server.set_handler(rack_handler)
|
105
97
|
@server.start
|
106
98
|
$stderr.printf("%s listening on %s:%s\n", version,
|
107
99
|
connector.host, connector.port) unless options[:quiet]
|
data/lib/mizuno/version.rb
CHANGED
metadata
CHANGED
@@ -1,102 +1,144 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mizuno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.6.5
|
4
5
|
prerelease:
|
5
|
-
version: 0.6.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Don Werve
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
16
|
-
version_requirements:
|
16
|
+
version_requirements: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.0.0
|
21
|
+
none: false
|
22
|
+
requirement: !ruby/object:Gem::Requirement
|
17
23
|
requirements:
|
18
24
|
- - ! '>='
|
19
25
|
- !ruby/object:Gem::Version
|
20
26
|
version: 1.0.0
|
21
27
|
none: false
|
22
|
-
requirement: *2056
|
23
28
|
prerelease: false
|
24
29
|
type: :runtime
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: ffi
|
27
|
-
version_requirements:
|
32
|
+
version_requirements: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ! '>='
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 1.0.0
|
37
|
+
none: false
|
38
|
+
requirement: !ruby/object:Gem::Requirement
|
28
39
|
requirements:
|
29
40
|
- - ! '>='
|
30
41
|
- !ruby/object:Gem::Version
|
31
42
|
version: 1.0.0
|
32
43
|
none: false
|
33
|
-
requirement: *2074
|
34
44
|
prerelease: false
|
35
45
|
type: :runtime
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: choice
|
38
|
-
version_requirements:
|
48
|
+
version_requirements: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ! '>='
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 0.1.0
|
53
|
+
none: false
|
54
|
+
requirement: !ruby/object:Gem::Requirement
|
39
55
|
requirements:
|
40
56
|
- - ! '>='
|
41
57
|
- !ruby/object:Gem::Version
|
42
58
|
version: 0.1.0
|
43
59
|
none: false
|
44
|
-
requirement: *2090
|
45
60
|
prerelease: false
|
46
61
|
type: :runtime
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: childprocess
|
49
|
-
version_requirements:
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.2.6
|
69
|
+
none: false
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
50
71
|
requirements:
|
51
72
|
- - ! '>='
|
52
73
|
- !ruby/object:Gem::Version
|
53
74
|
version: 0.2.6
|
54
75
|
none: false
|
55
|
-
requirement: *2106
|
56
76
|
prerelease: false
|
57
77
|
type: :runtime
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: rspec
|
60
|
-
version_requirements:
|
80
|
+
version_requirements: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 2.7.0
|
85
|
+
none: false
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
61
87
|
requirements:
|
62
88
|
- - ! '>='
|
63
89
|
- !ruby/object:Gem::Version
|
64
90
|
version: 2.7.0
|
65
91
|
none: false
|
66
|
-
requirement: *2122
|
67
92
|
prerelease: false
|
68
93
|
type: :development
|
69
94
|
- !ruby/object:Gem::Dependency
|
70
95
|
name: rspec-core
|
71
|
-
version_requirements:
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 2.7.0
|
101
|
+
none: false
|
102
|
+
requirement: !ruby/object:Gem::Requirement
|
72
103
|
requirements:
|
73
104
|
- - ! '>='
|
74
105
|
- !ruby/object:Gem::Version
|
75
106
|
version: 2.7.0
|
76
107
|
none: false
|
77
|
-
requirement: *2140
|
78
108
|
prerelease: false
|
79
109
|
type: :development
|
80
110
|
- !ruby/object:Gem::Dependency
|
81
111
|
name: json_pure
|
82
|
-
version_requirements:
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ! '>='
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: 1.6.0
|
117
|
+
none: false
|
118
|
+
requirement: !ruby/object:Gem::Requirement
|
83
119
|
requirements:
|
84
120
|
- - ! '>='
|
85
121
|
- !ruby/object:Gem::Version
|
86
122
|
version: 1.6.0
|
87
123
|
none: false
|
88
|
-
requirement: *2156
|
89
124
|
prerelease: false
|
90
125
|
type: :development
|
91
126
|
- !ruby/object:Gem::Dependency
|
92
127
|
name: nokogiri
|
93
|
-
version_requirements:
|
128
|
+
version_requirements: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ! '>='
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: !binary |-
|
133
|
+
MA==
|
134
|
+
none: false
|
135
|
+
requirement: !ruby/object:Gem::Requirement
|
94
136
|
requirements:
|
95
137
|
- - ! '>='
|
96
138
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
139
|
+
version: !binary |-
|
140
|
+
MA==
|
98
141
|
none: false
|
99
|
-
requirement: *2172
|
100
142
|
prerelease: false
|
101
143
|
type: :development
|
102
144
|
description: Jetty-powered running shoes for JRuby/Rack.
|
@@ -113,34 +155,63 @@ files:
|
|
113
155
|
- Gemfile
|
114
156
|
- mizuno.gemspec
|
115
157
|
- bin/mizuno
|
116
|
-
-
|
117
|
-
|
118
|
-
-
|
119
|
-
|
120
|
-
-
|
121
|
-
|
122
|
-
-
|
123
|
-
|
124
|
-
-
|
125
|
-
|
126
|
-
-
|
127
|
-
|
128
|
-
-
|
129
|
-
|
130
|
-
-
|
131
|
-
|
132
|
-
-
|
133
|
-
|
134
|
-
-
|
135
|
-
|
136
|
-
-
|
137
|
-
|
138
|
-
-
|
139
|
-
|
140
|
-
-
|
141
|
-
|
142
|
-
-
|
143
|
-
|
158
|
+
- !binary |-
|
159
|
+
bGliL21penVuby5yYg==
|
160
|
+
- !binary |-
|
161
|
+
bGliL21penVuby9jaG9pY2VzLnJi
|
162
|
+
- !binary |-
|
163
|
+
bGliL21penVuby9jbGllbnQucmI=
|
164
|
+
- !binary |-
|
165
|
+
bGliL21penVuby9jbGllbnRfZXhjaGFuZ2UucmI=
|
166
|
+
- !binary |-
|
167
|
+
bGliL21penVuby9jbGllbnRfcmVzcG9uc2UucmI=
|
168
|
+
- !binary |-
|
169
|
+
bGliL21penVuby9sb2dnZXIucmI=
|
170
|
+
- !binary |-
|
171
|
+
bGliL21penVuby9yYWNrX2hhbmRsZXIucmI=
|
172
|
+
- !binary |-
|
173
|
+
bGliL21penVuby9yZWxvYWRlci5yYg==
|
174
|
+
- !binary |-
|
175
|
+
bGliL21penVuby9ydW5uZXIucmI=
|
176
|
+
- !binary |-
|
177
|
+
bGliL21penVuby9zZXJ2ZXIucmI=
|
178
|
+
- !binary |-
|
179
|
+
bGliL21penVuby92ZXJzaW9uLnJi
|
180
|
+
- !binary |-
|
181
|
+
bGliL21penVuby9yYWNrL2NodW5rZWQucmI=
|
182
|
+
- !binary |-
|
183
|
+
bGliL3JhY2svaGFuZGxlci9taXp1bm8ucmI=
|
184
|
+
- !binary |-
|
185
|
+
bGliL2phdmEvamV0dHktY2xpZW50LTguMS4zLnYyMDEyMDQxNi5qYXI=
|
186
|
+
- !binary |-
|
187
|
+
bGliL2phdmEvamV0dHktY29udGludWF0aW9uLTguMS4zLnYyMDEyMDQxNi5q
|
188
|
+
YXI=
|
189
|
+
- !binary |-
|
190
|
+
bGliL2phdmEvamV0dHktaHR0cC04LjEuMy52MjAxMjA0MTYuamFy
|
191
|
+
- !binary |-
|
192
|
+
bGliL2phdmEvamV0dHktaW8tOC4xLjMudjIwMTIwNDE2Lmphcg==
|
193
|
+
- !binary |-
|
194
|
+
bGliL2phdmEvamV0dHktam14LTguMS4zLnYyMDEyMDQxNi5qYXI=
|
195
|
+
- !binary |-
|
196
|
+
bGliL2phdmEvamV0dHktc2VjdXJpdHktOC4xLjMudjIwMTIwNDE2Lmphcg==
|
197
|
+
- !binary |-
|
198
|
+
bGliL2phdmEvamV0dHktc2VydmVyLTguMS4zLnYyMDEyMDQxNi5qYXI=
|
199
|
+
- !binary |-
|
200
|
+
bGliL2phdmEvamV0dHktc2VydmxldC04LjEuMy52MjAxMjA0MTYuamFy
|
201
|
+
- !binary |-
|
202
|
+
bGliL2phdmEvamV0dHktc2VydmxldHMtOC4xLjMudjIwMTIwNDE2Lmphcg==
|
203
|
+
- !binary |-
|
204
|
+
bGliL2phdmEvamV0dHktdXRpbC04LjEuMy52MjAxMjA0MTYuamFy
|
205
|
+
- !binary |-
|
206
|
+
bGliL2phdmEvbG9nNGotMS4yLjE2Lmphcg==
|
207
|
+
- !binary |-
|
208
|
+
bGliL2phdmEvcmV3aW5kYWJsZS1pbnB1dC1zdHJlYW0uamFy
|
209
|
+
- !binary |-
|
210
|
+
bGliL2phdmEvc2VydmxldC1hcGktMy4wLmphcg==
|
211
|
+
- !binary |-
|
212
|
+
bGliL2phdmEvc2xmNGotYXBpLTEuNi40Lmphcg==
|
213
|
+
- !binary |-
|
214
|
+
bGliL2phdmEvc2xmNGotbG9nNGoxMi0xLjYuNC5qYXI=
|
144
215
|
homepage: http://github.com/matadon/mizuno
|
145
216
|
licenses: []
|
146
217
|
post_install_message:
|
@@ -151,7 +222,8 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
222
|
requirements:
|
152
223
|
- - ! '>='
|
153
224
|
- !ruby/object:Gem::Version
|
154
|
-
version:
|
225
|
+
version: !binary |-
|
226
|
+
MA==
|
155
227
|
none: false
|
156
228
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
229
|
requirements:
|
@@ -161,9 +233,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
161
233
|
none: false
|
162
234
|
requirements: []
|
163
235
|
rubyforge_project:
|
164
|
-
rubygems_version: 1.8.
|
236
|
+
rubygems_version: 1.8.24
|
165
237
|
signing_key:
|
166
238
|
specification_version: 3
|
167
239
|
summary: Rack handler for Jetty 8 on JRuby. Features multithreading, event-driven I/O, and async support.
|
168
240
|
test_files: []
|
169
|
-
...
|