Permalink
Browse files

Remove unused StringIO, expect options hash with application instead …

…of application itself
  • Loading branch information...
1 parent 4788395 commit e64aba4e8fabaaa100e88d8fa286a61f4becd5d2 @marekjelen committed Mar 31, 2012
Showing with 6 additions and 7 deletions.
  1. +6 −7 lib/thick/server_handler.rb
@@ -1,12 +1,10 @@
-require 'stringio'
-
module Thick
class ServerHandler < Thick::Java::SimpleChannelUpstreamHandler
- def initialize(application)
+ def initialize(options)
super()
- @application = application
+ @options = options
end
def channelConnected(context, event)
@@ -32,7 +30,7 @@ def serve_file(context, file, from = 0, to = nil)
def on_request(context, request)
# Serve file if exists in public directory
- file = File.join('public', request.uri)
+ file = File.join(@options[:directory], 'public', request.uri)
return serve_file(context, file).addListener(Thick::Java::ChannelFutureListener::CLOSE) if !request.uri.index('..') && File.exists?(file) && !File.directory?(file)
query_string = request.uri.split('?', 2)
@@ -53,7 +51,8 @@ def on_request(context, request)
'SERVER_NAME' => 'localhost', # ToDo: Be more precise!
'SERVER_PORT' => '8080', # ToDo: Be more precise!
# Thick specific
- 'thick.async' => AsyncResponse.new(context)
+ 'thick.async' => AsyncResponse.new(context),
+ 'thick.options' => @options
}
# Get content length if available
@@ -83,7 +82,7 @@ def on_chunk(context, chunk)
end
def handle_request(context)
- response = @application.call(@env)
+ response = @options[:application].call(@env)
# Let the application make the response as it wants
if @env['thick.async'].custom?

0 comments on commit e64aba4

Please sign in to comment.