Sha256: c5dee1f00bc869eb9eee0e03ed23b96335d3faac273552c0c5a08f827c2f3500

Contents?: true

Size: 1.72 KB

Versions: 57

Compression:

Stored size: 1.72 KB

Contents

#
# httpservlet.rb -- HTTPServlet Module
#
# Author: IPR -- Internet Programming with Ruby -- writers
# Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU Yuuzou
# Copyright (c) 2002 Internet Programming with Ruby writers. All rights
# reserved.
#
# $IPR: abstract.rb,v 1.24 2003/07/11 11:16:46 gotoyuzo Exp $

require 'thread'

require 'webrick/htmlutils'
require 'webrick/httputils'
require 'webrick/httpstatus'

module WEBrick
  module HTTPServlet
    class HTTPServletError < StandardError; end

    class AbstractServlet
      def self.get_instance(config, *options)
        self.new(config, *options)
      end

      def initialize(server, *options)
        @server = @config = server
        @logger = @server[:Logger]
        @options = options
      end

      def service(req, res)
        method_name = "do_" + req.request_method.gsub(/-/, "_")
        if respond_to?(method_name)
          __send__(method_name, req, res)
        else
          raise HTTPStatus::MethodNotAllowed,
                "unsupported method `#{req.request_method}'."
        end
      end

      def do_GET(req, res)
        raise HTTPStatus::NotFound, "not found."
      end

      def do_HEAD(req, res)
        do_GET(req, res)
      end

      def do_OPTIONS(req, res)
        m = self.methods.grep(/\Ado_([A-Z]+)\z/) {$1}
        m.sort!
        res["allow"] = m.join(",")
      end

      private

      def redirect_to_directory_uri(req, res)
        if req.path[-1] != ?/
          location = WEBrick::HTTPUtils.escape_path(req.path + "/")
          if req.query_string && req.query_string.bytesize > 0
            location << "?" << req.query_string
          end
          res.set_redirect(HTTPStatus::MovedPermanently, location)
        end
      end
    end

  end
end

Version data entries

57 entries across 57 versions & 3 rubygems

Version Path
rhodes-7.6.0 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-7.5.1 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-7.4.1 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-7.1.17 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-6.2.0 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-6.0.11 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.18 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.17 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.15 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.0.22 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.2 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.0.7 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.0.3 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-5.5.0 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
tauplatform-1.0.3 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
tauplatform-1.0.2 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
tauplatform-1.0.1 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-3.5.1.12 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-3.3.5 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb
rhodes-3.4.2 spec/framework_spec/extensions/test-libs/webrick/httpservlet/abstract.rb