1#
2# config.rb -- Default configurations.
3#
4# Author: IPR -- Internet Programming with Ruby -- writers
5# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou
6# Copyright (c) 2003 Internet Programming with Ruby writers. All rights
7# reserved.
8#
9# $IPR: config.rb,v 1.52 2003/07/22 19:20:42 gotoyuzo Exp $
10
11require 'webrick/version'
12require 'webrick/httpversion'
13require 'webrick/httputils'
14require 'webrick/utils'
15require 'webrick/log'
16
17module WEBrick
18  module Config
19    LIBDIR = File::dirname(__FILE__) # :nodoc:
20
21    # for GenericServer
22    General = {
23      :ServerName     => Utils::getservername,
24      :BindAddress    => nil,   # "0.0.0.0" or "::" or nil
25      :Port           => nil,   # users MUST specify this!!
26      :MaxClients     => 100,   # maximum number of the concurrent connections
27      :ServerType     => nil,   # default: WEBrick::SimpleServer
28      :Logger         => nil,   # default: WEBrick::Log.new
29      :ServerSoftware => "WEBrick/#{WEBrick::VERSION} " +
30                         "(Ruby/#{RUBY_VERSION}/#{RUBY_RELEASE_DATE})",
31      :TempDir        => ENV['TMPDIR']||ENV['TMP']||ENV['TEMP']||'/tmp',
32      :DoNotListen    => false,
33      :StartCallback  => nil,
34      :StopCallback   => nil,
35      :AcceptCallback => nil,
36      :DoNotReverseLookup => nil,
37      :ShutdownSocketWithoutClose => false,
38    }
39
40    # for HTTPServer, HTTPRequest, HTTPResponse ...
41    HTTP = General.dup.update(
42      :Port           => 80,
43      :RequestTimeout => 30,
44      :HTTPVersion    => HTTPVersion.new("1.1"),
45      :AccessLog      => nil,
46      :MimeTypes      => HTTPUtils::DefaultMimeTypes,
47      :DirectoryIndex => ["index.html","index.htm","index.cgi","index.rhtml"],
48      :DocumentRoot   => nil,
49      :DocumentRootOptions => { :FancyIndexing => true },
50      :RequestCallback => nil,
51      :ServerAlias    => nil,
52      :InputBufferSize  => 65536, # input buffer size in reading request body
53      :OutputBufferSize => 65536, # output buffer size in sending File or IO
54
55      # for HTTPProxyServer
56      :ProxyAuthProc  => nil,
57      :ProxyContentHandler => nil,
58      :ProxyVia       => true,
59      :ProxyTimeout   => true,
60      :ProxyURI       => nil,
61
62      :CGIInterpreter => nil,
63      :CGIPathEnv     => nil,
64
65      # workaround: if Request-URIs contain 8bit chars,
66      # they should be escaped before calling of URI::parse().
67      :Escape8bitURI  => false
68    )
69
70    ##
71    # Default configuration for WEBrick::HTTPServlet::FileHandler
72    #
73    # :AcceptableLanguages::
74    #   Array of languages allowed for accept-language.  There is no default
75    # :DirectoryCallback::
76    #   Allows preprocessing of directory requests.  There is no default
77    #   callback.
78    # :FancyIndexing::
79    #   If true, show an index for directories.  The default is true.
80    # :FileCallback::
81    #   Allows preprocessing of file requests.  There is no default callback.
82    # :HandlerCallback::
83    #   Allows preprocessing of requests.  There is no default callback.
84    # :HandlerTable::
85    #   Maps file suffixes to file handlers.  DefaultFileHandler is used by
86    #   default but any servlet can be used.
87    # :NondisclosureName::
88    #   Do not show files matching this array of globs.  .ht* and *~ are
89    #   excluded by default.
90    # :UserDir::
91    #   Directory inside ~user to serve content from for /~user requests.
92    #   Only works if mounted on /.  Disabled by default.
93
94    FileHandler = {
95      :NondisclosureName => [".ht*", "*~"],
96      :FancyIndexing     => false,
97      :HandlerTable      => {},
98      :HandlerCallback   => nil,
99      :DirectoryCallback => nil,
100      :FileCallback      => nil,
101      :UserDir           => nil,  # e.g. "public_html"
102      :AcceptableLanguages => []  # ["en", "ja", ... ]
103    }
104
105    ##
106    # Default configuration for WEBrick::HTTPAuth::BasicAuth
107    #
108    # :AutoReloadUserDB:: Reload the user database provided by :UserDB
109    #                     automatically?
110
111    BasicAuth = {
112      :AutoReloadUserDB     => true,
113    }
114
115    ##
116    # Default configuration for WEBrick::HTTPAuth::DigestAuth.
117    #
118    # :Algorithm:: MD5, MD5-sess (default), SHA1, SHA1-sess
119    # :Domain:: An Array of URIs that define the protected space
120    # :Qop:: 'auth' for authentication, 'auth-int' for integrity protection or
121    #        both
122    # :UseOpaque:: Should the server send opaque values to the client?  This
123    #              helps prevent replay attacks.
124    # :CheckNc:: Should the server check the nonce count?  This helps the
125    #            server detect replay attacks.
126    # :UseAuthenticationInfoHeader:: Should the server send an
127    #                                AuthenticationInfo header?
128    # :AutoReloadUserDB:: Reload the user database provided by :UserDB
129    #                     automatically?
130    # :NonceExpirePeriod:: How long should we store used nonces?  Default is
131    #                      30 minutes.
132    # :NonceExpireDelta:: How long is a nonce valid?  Default is 1 minute
133    # :InternetExplorerHack:: Hack which allows Internet Explorer to work.
134    # :OperaHack:: Hack which allows Opera to work.
135
136    DigestAuth = {
137      :Algorithm            => 'MD5-sess', # or 'MD5'
138      :Domain               => nil,        # an array includes domain names.
139      :Qop                  => [ 'auth' ], # 'auth' or 'auth-int' or both.
140      :UseOpaque            => true,
141      :UseNextNonce         => false,
142      :CheckNc              => false,
143      :UseAuthenticationInfoHeader => true,
144      :AutoReloadUserDB     => true,
145      :NonceExpirePeriod    => 30*60,
146      :NonceExpireDelta     => 60,
147      :InternetExplorerHack => true,
148      :OperaHack            => true,
149    }
150  end
151end
152