def servlet_to_rack(request)
            # The Rack request that we will pass on.
            env = Hash.new

            # Map Servlet bits to Rack bits.
            env['REQUEST_METHOD'] = request.getMethod
            env['QUERY_STRING'] = request.getQueryString.to_s
            env['SERVER_NAME'] = request.getServerName
            env['SERVER_PORT'] = request.getServerPort.to_s
            env['rack.version'] = Rack::VERSION
            env['rack.url_scheme'] = request.getScheme
            env['HTTP_VERSION'] = request.getProtocol
            env["SERVER_PROTOCOL"] = request.getProtocol
            env['REMOTE_ADDR'] = request.getRemoteAddr
            env['REMOTE_HOST'] = request.getRemoteHost

            # request.getPathInfo seems to be blank, so we're using the URI.
            env['REQUEST_PATH'] = request.getRequestURI
            env['PATH_INFO'] = request.getRequestURI
            env['SCRIPT_NAME'] = ""

            # Rack says URI, but it hands off a URL.
            env['REQUEST_URI'] = request.getRequestURL.to_s

            # Java chops off the query string, but a Rack application will
            # expect it, so we'll add it back if present
            env['REQUEST_URI'] << "?#{env['QUERY_STRING']}" \
                if env['QUERY_STRING']

            # JRuby is like the matrix, only there's no spoon or fork().
            env['rack.multiprocess'] = false
            env['rack.multithread'] = true
            env['rack.run_once'] = false

            # The input stream is a wrapper around the Java InputStream.
            env['rack.input'] = @server.rewindable(request)

            # Force encoding if we're on Ruby 1.9
            env['rack.input'].set_encoding(Encoding.find("ASCII-8BIT")) \
                if env['rack.input'].respond_to?(:set_encoding)

            # Populate the HTTP headers.
            request.getHeaderNames.each do |header_name|
                header = header_name.to_s.upcase.tr('-', '_')
                env["HTTP_#{header}"] = request.getHeader(header_name)
            end

            # Rack Weirdness: HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH
            # both need to have the HTTP_ part dropped.
            env["CONTENT_TYPE"] = env.delete("HTTP_CONTENT_TYPE") \
                if env["HTTP_CONTENT_TYPE"]
            env["CONTENT_LENGTH"] = env.delete("HTTP_CONTENT_LENGTH") \
                if env["HTTP_CONTENT_LENGTH"]

            # Route errors through the logger.
            env['rack.errors'] ||= @server.logger
            env['rack.logger'] ||= @server.logger

            # All done, hand back the Rack request.
            return(env)
        end
def servlet_to_rack(request)
            
            env = Hash.new

            
            env['REQUEST_METHOD'] = request.getMethod
            env['QUERY_STRING'] = request.getQueryString.to_s
            env['SERVER_NAME'] = request.getServerName
            env['SERVER_PORT'] = request.getServerPort.to_s
            env['rack.version'] = Rack::VERSION
            env['rack.url_scheme'] = request.getScheme
            env['HTTP_VERSION'] = request.getProtocol
            env["SERVER_PROTOCOL"] = request.getProtocol
            env['REMOTE_ADDR'] = request.getRemoteAddr
            env['REMOTE_HOST'] = request.getRemoteHost

            
            env['REQUEST_PATH'] = request.getRequestURI
            env['PATH_INFO'] = request.getRequestURI
            env['SCRIPT_NAME'] = ""

            
            env['REQUEST_URI'] = request.getRequestURL.to_s

            
            
            env['REQUEST_URI'] << "?
                if env['QUERY_STRING']

            
            env['rack.multiprocess'] = false
            env['rack.multithread'] = true
            env['rack.run_once'] = false

            
            env['rack.input'] = @server.rewindable(request)

            
            env['rack.input'].set_encoding(Encoding.find("ASCII-8BIT")) \
                if env['rack.input'].respond_to?(:set_encoding)

            
            request.getHeaderNames.each do |header_name|
                header = header_name.to_s.upcase.tr('-', '_')
                env["HTTP_
            end

            
            
            env["CONTENT_TYPE"] = env.delete("HTTP_CONTENT_TYPE") \
                if env["HTTP_CONTENT_TYPE"]
            env["CONTENT_LENGTH"] = env.delete("HTTP_CONTENT_LENGTH") \
                if env["HTTP_CONTENT_LENGTH"]

            
            env['rack.errors'] ||= @server.logger
            env['rack.logger'] ||= @server.logger

            
            return(env)
        end
def servlet_to_rack ( request ) # The Rack request that we will pass on. env = Hash . new # Map Servlet bits to Rack bits. env [ 'REQUEST_METHOD' ] = request . getMethod env [ 'QUERY_STRING' ] = request . getQueryString . to_s env [ 'SERVER_NAME' ] = request . getServerName env [ 'SERVER_PORT' ] = request . getServerPort . to_s env [ 'rack.version' ] = Rack :: VERSION env [ 'rack.url_scheme' ] = request . getScheme env [ 'HTTP_VERSION' ] = request . getProtocol env [ "SERVER_PROTOCOL" ] = request . getProtocol env [ 'REMOTE_ADDR' ] = request . getRemoteAddr env [ 'REMOTE_HOST' ] = request . getRemoteHost # request.getPathInfo seems to be blank, so we're using the URI. env [ 'REQUEST_PATH' ] = request . getRequestURI env [ 'PATH_INFO' ] = request . getRequestURI env [ 'SCRIPT_NAME' ] = "" # Rack says URI, but it hands off a URL. env [ 'REQUEST_URI' ] = request . getRequestURL . to_s # Java chops off the query string, but a Rack application will # expect it, so we'll add it back if present env [ 'REQUEST_URI' ] << "?#{env['QUERY_STRING']}" if env [ 'QUERY_STRING' ] # JRuby is like the matrix, only there's no spoon or fork(). env [ 'rack.multiprocess' ] = false env [ 'rack.multithread' ] = true env [ 'rack.run_once' ] = false # The input stream is a wrapper around the Java InputStream. env [ 'rack.input' ] = @server . rewindable ( request ) # Force encoding if we're on Ruby 1.9 env [ 'rack.input' ] . set_encoding ( Encoding . find ( "ASCII-8BIT" ) ) if env [ 'rack.input' ] . respond_to? ( :set_encoding ) # Populate the HTTP headers. request . getHeaderNames . each do | header_name | header = header_name . to_s . upcase . tr ( '-' , '_' ) env [ "HTTP_#{header}" ] = request . getHeader ( header_name ) end # Rack Weirdness: HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH # both need to have the HTTP_ part dropped. env [ "CONTENT_TYPE" ] = env . delete ( "HTTP_CONTENT_TYPE" ) if env [ "HTTP_CONTENT_TYPE" ] env [ "CONTENT_LENGTH" ] = env . delete ( "HTTP_CONTENT_LENGTH" ) if env [ "HTTP_CONTENT_LENGTH" ] # Route errors through the logger. env [ 'rack.errors' ] ||= @server . logger env [ 'rack.logger' ] ||= @server . logger # All done, hand back the Rack request. return ( env ) end
Turns a Servlet request into a Rack request hash.
Turns a Servlet request into a Rack request hash .