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 CHANGED
@@ -1,6 +1,8 @@
1
1
  *.sw?
2
2
  *.DS_Store
3
3
  *.gem
4
+ .rbenv-version
5
+ .rvm
4
6
  Gemfile.lock
5
7
  archive/
6
8
  doc/
@@ -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 Java servlet.
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 'javax.servlet.http.HttpServlet'
8
+ java_import 'org.eclipse.jetty.server.handler.AbstractHandler'
15
9
 
16
- class RackServlet < HttpServlet
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
- # servlet container.
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 Java Servlet) and dispatches it to
39
- # the rack application setup via [rackup]. All this really involves
40
- # is translating the various bits of the Servlet API into the Rack
41
- # API on the way in, and translating the response back on the way
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 service(request, response)
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 { |l| output.write(l.to_java_bytes) }
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.
@@ -141,7 +141,7 @@ module Mizuno
141
141
  return unless file
142
142
  stat = File.stat(file)
143
143
  stat.file? ? stat.mtime.to_i : nil
144
- rescue Errno::ENOENT, Errno::ENOTDIR
144
+ rescue Errno::ENOENT, Errno::ENOTDIR, Errno::ESRCH
145
145
  nil
146
146
  end
147
147
  end
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 jetty-servlets jetty-util
8
- servlet-api rewindable-input-stream))
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/rack_servlet'
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
- rack_servlet = RackServlet.new(self)
99
- rack_servlet.rackup(app)
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(app_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]
@@ -1,3 +1,3 @@
1
1
  module Mizuno
2
- VERSION = "0.6.4"
2
+ VERSION = "0.6.5"
3
3
  end
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-05-15 00:00:00.000000000Z
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: &2056 !ruby/object:Gem::Requirement
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: &2074 !ruby/object:Gem::Requirement
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: &2090 !ruby/object:Gem::Requirement
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: &2106 !ruby/object:Gem::Requirement
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: &2122 !ruby/object:Gem::Requirement
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: &2140 !ruby/object:Gem::Requirement
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: &2156 !ruby/object:Gem::Requirement
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: &2172 !ruby/object:Gem::Requirement
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: '0'
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
- - lib/mizuno.rb
117
- - lib/mizuno/choices.rb
118
- - lib/mizuno/client.rb
119
- - lib/mizuno/client_exchange.rb
120
- - lib/mizuno/client_response.rb
121
- - lib/mizuno/logger.rb
122
- - lib/mizuno/rack_servlet.rb
123
- - lib/mizuno/reloader.rb
124
- - lib/mizuno/runner.rb
125
- - lib/mizuno/server.rb
126
- - lib/mizuno/version.rb
127
- - lib/mizuno/rack/chunked.rb
128
- - lib/rack/handler/mizuno.rb
129
- - lib/java/jetty-client-8.1.3.v20120416.jar
130
- - lib/java/jetty-continuation-8.1.3.v20120416.jar
131
- - lib/java/jetty-http-8.1.3.v20120416.jar
132
- - lib/java/jetty-io-8.1.3.v20120416.jar
133
- - lib/java/jetty-jmx-8.1.3.v20120416.jar
134
- - lib/java/jetty-security-8.1.3.v20120416.jar
135
- - lib/java/jetty-server-8.1.3.v20120416.jar
136
- - lib/java/jetty-servlet-8.1.3.v20120416.jar
137
- - lib/java/jetty-servlets-8.1.3.v20120416.jar
138
- - lib/java/jetty-util-8.1.3.v20120416.jar
139
- - lib/java/log4j-1.2.16.jar
140
- - lib/java/rewindable-input-stream.jar
141
- - lib/java/servlet-api-3.0.jar
142
- - lib/java/slf4j-api-1.6.4.jar
143
- - lib/java/slf4j-log4j12-1.6.4.jar
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: '0'
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.15
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
- ...