module WEBrick
  module HTTPServlet
    class DefaultFileHandler < AbstractServlet
      @local_path: String

      def initialize: (HTTPServer server, String local_path) -> void

      def do_GET: (HTTPRequest req, HTTPResponse res) -> void

      def not_modified?: (HTTPRequest req, HTTPResponse res, Time mtime, String etag) -> bool

      # returns a lambda for webrick/httpresponse.rb send_body_proc
      def multipart_body: (File body, Array[[Numeric, Numeric]] parts, String boundary, String mtype, Integer filesize) -> HTTPResponse::_CallableBody

      def make_partial_content: (HTTPRequest req, HTTPResponse res, String filename, Integer filesize) -> void

      def prepare_range: (Range[Integer] range, Integer filesize) -> [Numeric, Numeric]
    end

    class FileHandler < AbstractServlet
      @config: AbstractServlet::_Config

      @logger: Log

      @root: String

      @options: Hash[Symbol, untyped]

      HandlerTable: Hash[String, singleton(AbstractServlet)]

      def self.add_handler: (String suffix, singleton(AbstractServlet) handler) -> singleton(AbstractServlet)

      def self.remove_handler: (String suffix) -> singleton(AbstractServlet)

      def initialize: (HTTPServer server, String root, ?Hash[Symbol, untyped] options, ?Hash[Symbol, untyped] default) -> void

      def set_filesystem_encoding: (String str) -> String

      def service: (HTTPRequest req, HTTPResponse res) -> void

      def do_GET: (HTTPRequest req, HTTPResponse res) -> void

      def do_POST: (HTTPRequest req, HTTPResponse res) -> void

      def do_OPTIONS: (HTTPRequest req, HTTPResponse res) -> void

      private

      def trailing_pathsep?: (String path) -> bool

      def prevent_directory_traversal: (HTTPRequest req, HTTPResponse res) -> void

      def exec_handler: (HTTPRequest req, HTTPResponse res) -> bool

      def get_handler: (HTTPRequest req, HTTPResponse res) -> singleton(AbstractServlet)

      def set_filename: (HTTPRequest req, HTTPResponse res) -> bool

      def check_filename: (HTTPRequest req, HTTPResponse res, String name) -> void

      def shift_path_info: (HTTPRequest req, HTTPResponse res, String path_info, ?String? base) -> void

      def search_index_file: (HTTPRequest req, HTTPResponse res) -> String?

      def search_file: (HTTPRequest req, HTTPResponse res, String basename) -> String?

      def call_callback: (Symbol callback_name, HTTPRequest req, HTTPResponse res) -> void

      def windows_ambiguous_name?: (String name) -> bool

      def nondisclosure_name?: (String name) -> bool

      def set_dir_list: (HTTPRequest req, HTTPResponse res) -> void
    end
  end
end
