rubysl-webrick 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +14 -6
  2. data/.travis.yml +5 -6
  3. data/lib/rubysl/webrick/version.rb +1 -1
  4. data/lib/rubysl/webrick/webrick.rb +199 -2
  5. data/lib/webrick/accesslog.rb +96 -5
  6. data/lib/webrick/cgi.rb +80 -29
  7. data/lib/webrick/compat.rb +20 -0
  8. data/lib/webrick/config.rb +59 -5
  9. data/lib/webrick/cookie.rb +66 -5
  10. data/lib/webrick/htmlutils.rb +4 -1
  11. data/lib/webrick/httpauth.rb +53 -3
  12. data/lib/webrick/httpauth/authenticator.rb +53 -16
  13. data/lib/webrick/httpauth/basicauth.rb +45 -2
  14. data/lib/webrick/httpauth/digestauth.rb +82 -17
  15. data/lib/webrick/httpauth/htdigest.rb +38 -1
  16. data/lib/webrick/httpauth/htgroup.rb +32 -0
  17. data/lib/webrick/httpauth/htpasswd.rb +40 -2
  18. data/lib/webrick/httpauth/userdb.rb +27 -4
  19. data/lib/webrick/httpproxy.rb +197 -112
  20. data/lib/webrick/httprequest.rb +268 -50
  21. data/lib/webrick/httpresponse.rb +170 -33
  22. data/lib/webrick/https.rb +26 -3
  23. data/lib/webrick/httpserver.rb +75 -7
  24. data/lib/webrick/httpservlet/abstract.rb +88 -6
  25. data/lib/webrick/httpservlet/cgi_runner.rb +5 -4
  26. data/lib/webrick/httpservlet/cgihandler.rb +37 -18
  27. data/lib/webrick/httpservlet/erbhandler.rb +40 -7
  28. data/lib/webrick/httpservlet/filehandler.rb +116 -28
  29. data/lib/webrick/httpservlet/prochandler.rb +17 -4
  30. data/lib/webrick/httpstatus.rb +86 -18
  31. data/lib/webrick/httputils.rb +131 -23
  32. data/lib/webrick/httpversion.rb +28 -2
  33. data/lib/webrick/log.rb +72 -5
  34. data/lib/webrick/server.rb +158 -33
  35. data/lib/webrick/ssl.rb +78 -9
  36. data/lib/webrick/utils.rb +151 -5
  37. data/lib/webrick/version.rb +5 -1
  38. data/rubysl-webrick.gemspec +0 -1
  39. metadata +12 -24
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: d8994245d4c318c3596b0c96a9608c372d0fd7fd
4
- data.tar.gz: 4741b54181f8e4ace05485f7985d1fcc3e3fd28e
5
- SHA512:
6
- metadata.gz: 9f294bfa3fe38668ae4bc1d5a82ddde945038cb1823e3f1f7dceb6ceb16c5afc8bdc74dcfa63d2fea181dc2c51e38de468c85e676187380dc3f472f0ae900158
7
- data.tar.gz: 747dcf8e42c579a4cf766167e5b56a7d58160277b0f48a889c40f82d175ecae054ed83275d8870a01d956c95f3574865924bf85923511f958b19243e36928019
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NTkyOGI2NzczYTNjMTlmYjI2YTdjNmM2ZDRlYjc4ODZhZTY5NTUwMg==
5
+ data.tar.gz: !binary |-
6
+ NGViN2JmMzdiZDNiMjM5OTM5Mzg4YzY2OWJlZjg4NmUzYmMzOTJkOA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NWM4MmVkNzFiM2RiNDVkNTY2MjBjNzkxYzNhZDNkOGVjOWViNTkxNjg5YmU1
10
+ NjVlOTViNDk0M2RhMDMwYjJiZTY5YWJjM2Y4OWI3NWQ4ODExMzlmOTYxZjYx
11
+ OGFkNTE3YjM1MDU4YTdmOWFjYjFmNDkwMjJkMTI3OTM1MmE0OGM=
12
+ data.tar.gz: !binary |-
13
+ YTNkNjVlZDA0YTQxOTUyMWJlNmQwMWY4NTA1NzI4ZTA5MjY2N2RmY2QyN2Vl
14
+ YTAyODUwYjliYjliNjYwOWVlMTQyNWZmZDI3NzhmZTE2NDViYTZkYjM2ODZm
15
+ ZTgwMzdmMTc1ODEyZDRkMTMzMmEzMjA5MGIzMGExNmYxZmM4NDk=
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
- before_install:
3
- - gem update --system
4
- - gem --version
5
- - gem install rubysl-bundler
6
- script: bundle exec mspec spec
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec
7
5
  rvm:
8
- - rbx-nightly-18mode
6
+ - 1.9.3
7
+ - rbx-nightly-19mode
@@ -1,5 +1,5 @@
1
1
  module RubySL
2
2
  module WEBrick
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -1,13 +1,210 @@
1
+ ##
2
+ # = WEB server toolkit.
1
3
  #
2
- # WEBrick -- WEB server toolkit.
4
+ # WEBrick is an HTTP server toolkit that can be configured as an HTTPS server,
5
+ # a proxy server, and a virtual-host server. WEBrick features complete
6
+ # logging of both server operations and HTTP access. WEBrick supports both
7
+ # basic and digest authentication in addition to algorithms not in RFC 2617.
8
+ #
9
+ # A WEBrick server can be composed of multiple WEBrick servers or servlets to
10
+ # provide differing behavior on a per-host or per-path basis. WEBrick
11
+ # includes servlets for handling CGI scripts, ERb pages, ruby blocks and
12
+ # directory listings.
13
+ #
14
+ # WEBrick also includes tools for daemonizing a process and starting a process
15
+ # at a higher privilege level and dropping permissions.
16
+ #
17
+ # == Starting an HTTP server
18
+ #
19
+ # To create a new WEBrick::HTTPServer that will listen to connections on port
20
+ # 8000 and serve documents from the current user's public_html folder:
21
+ #
22
+ # require 'webrick'
23
+ #
24
+ # root = File.expand_path '~/public_html'
25
+ # server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => root
26
+ #
27
+ # To run the server you will need to provide a suitable shutdown hook as
28
+ # starting the server blocks the current thread:
29
+ #
30
+ # trap 'INT' do server.shutdown end
31
+ #
32
+ # server.start
33
+ #
34
+ # == Custom Behavior
35
+ #
36
+ # The easiest way to have a server perform custom operations is through
37
+ # WEBrick::HTTPServer#mount_proc. The block given will be called with a
38
+ # WEBrick::HTTPRequest with request info and a WEBrick::HTTPResponse which
39
+ # must be filled in appropriately:
40
+ #
41
+ # server.mount_proc '/' do |req, res|
42
+ # res.body = 'Hello, world!'
43
+ # end
44
+ #
45
+ # Remember that <tt>server.mount_proc</tt> must <tt>server.start</tt>.
46
+ #
47
+ # == Servlets
48
+ #
49
+ # Advanced custom behavior can be obtained through mounting a subclass of
50
+ # WEBrick::HTTPServlet::AbstractServlet. Servlets provide more modularity
51
+ # when writing an HTTP server than mount_proc allows. Here is a simple
52
+ # servlet:
53
+ #
54
+ # class Simple < WEBrick::HTTPServlet::AbstractServlet
55
+ # def do_GET request, response
56
+ # status, content_type, body = do_stuff_with request
57
+ #
58
+ # response.status = 200
59
+ # response['Content-Type'] = 'text/plain'
60
+ # response.body = 'Hello, World!'
61
+ # end
62
+ # end
63
+ #
64
+ # To initialize the servlet you mount it on the server:
65
+ #
66
+ # server.mount '/simple', Simple
67
+ #
68
+ # See WEBrick::HTTPServlet::AbstractServlet for more details.
69
+ #
70
+ # == Virtual Hosts
71
+ #
72
+ # A server can act as a virtual host for multiple host names. After creating
73
+ # the listening host, additional hosts that do not listen can be created and
74
+ # attached as virtual hosts:
75
+ #
76
+ # server = WEBrick::HTTPServer.new # ...
77
+ #
78
+ # vhost = WEBrick::HTTPServer.new :ServerName => 'vhost.example',
79
+ # :DoNotListen => true, # ...
80
+ # vhost.mount '/', ...
81
+ #
82
+ # server.virtual_host vhost
83
+ #
84
+ # If no +:DocumentRoot+ is provided and no servlets or procs are mounted on the
85
+ # main server it will return 404 for all URLs.
86
+ #
87
+ # == HTTPS
88
+ #
89
+ # To create an HTTPS server you only need to enable SSL and provide an SSL
90
+ # certificate name:
91
+ #
92
+ # require 'webrick'
93
+ # require 'webrick/https'
94
+ #
95
+ # cert_name = [
96
+ # %w[CN localhost],
97
+ # ]
98
+ #
99
+ # server = WEBrick::HTTPServer.new(:Port => 8000,
100
+ # :SSLEnable => true,
101
+ # :SSLCertName => cert_name)
102
+ #
103
+ # This will start the server with a self-generated self-signed certificate.
104
+ # The certificate will be changed every time the server is restarted.
105
+ #
106
+ # To create a server with a pre-determined key and certificate you can provide
107
+ # them:
108
+ #
109
+ # require 'webrick'
110
+ # require 'webrick/https'
111
+ # require 'openssl'
112
+ #
113
+ # cert = OpenSSL::X509::Certificate.new File.read '/path/to/cert.pem'
114
+ # pkey = OpenSSL::PKey::RSA.new File.read '/path/to/pkey.pem'
115
+ #
116
+ # server = WEBrick::HTTPServer.new(:Port => 8000,
117
+ # :SSLEnable => true,
118
+ # :SSLCertificate => cert,
119
+ # :SSLPrivateKey => pkey)
120
+ #
121
+ # == Proxy Server
122
+ #
123
+ # WEBrick can act as a proxy server:
124
+ #
125
+ # require 'webrick'
126
+ # require 'webrick/httpproxy'
127
+ #
128
+ # proxy = WEBrick::HTTPProxyServer.new :Port => 8000
129
+ #
130
+ # trap 'INT' do proxy.shutdown end
131
+ #
132
+ # See WEBrick::HTTPProxy for further details including modifying proxied
133
+ # responses.
134
+ #
135
+ # == Basic and Digest authentication
136
+ #
137
+ # WEBrick provides both Basic and Digest authentication for regular and proxy
138
+ # servers. See WEBrick::HTTPAuth, WEBrick::HTTPAuth::BasicAuth and
139
+ # WEBrick::HTTPAuth::DigestAuth.
140
+ #
141
+ # == WEBrick as a Production Web Server
142
+ #
143
+ # WEBrick can be run as a production server for small loads.
144
+ #
145
+ # === Daemonizing
146
+ #
147
+ # To start a WEBrick server as a daemon simple run WEBrick::Daemon.start
148
+ # before starting the server.
149
+ #
150
+ # === Dropping Permissions
151
+ #
152
+ # WEBrick can be started as one user to gain permission to bind to port 80 or
153
+ # 443 for serving HTTP or HTTPS traffic then can drop these permissions for
154
+ # regular operation. To listen on all interfaces for HTTP traffic:
155
+ #
156
+ # sockets = WEBrick::Utils.create_listeners nil, 80
157
+ #
158
+ # Then drop privileges:
159
+ #
160
+ # WEBrick::Utils.su 'www'
161
+ #
162
+ # Then create a server that does not listen by default:
163
+ #
164
+ # server = WEBrick::HTTPServer.new :DoNotListen => true, # ...
165
+ #
166
+ # Then overwrite the listening sockets with the port 80 sockets:
167
+ #
168
+ # server.listeners.replace sockets
169
+ #
170
+ # === Logging
171
+ #
172
+ # WEBrick can separately log server operations and end-user access. For
173
+ # server operations:
174
+ #
175
+ # log_file = File.open '/var/log/webrick.log', 'a+'
176
+ # log = WEBrick::Log.new log_file
177
+ #
178
+ # For user access logging:
179
+ #
180
+ # access_log = [
181
+ # [log_file, WEBrick::AccessLog::COMBINED_LOG_FORMAT],
182
+ # ]
183
+ #
184
+ # server = WEBrick::HTTPServer.new :Logger => log, :AccessLog => access_log
185
+ #
186
+ # See WEBrick::AccessLog for further log formats.
187
+ #
188
+ # === Log Rotation
189
+ #
190
+ # To rotate logs in WEBrick on a HUP signal (like syslogd can send), open the
191
+ # log file in 'a+' mode (as above) and trap 'HUP' to reopen the log file:
192
+ #
193
+ # trap 'HUP' do log_file.reopen '/path/to/webrick.log', 'a+'
194
+ #
195
+ # == Copyright
3
196
  #
4
197
  # Author: IPR -- Internet Programming with Ruby -- writers
198
+ #
5
199
  # Copyright (c) 2000 TAKAHASHI Masayoshi, GOTOU YUUZOU
6
200
  # Copyright (c) 2002 Internet Programming with Ruby writers. All rights
7
201
  # reserved.
8
- #
202
+ #--
9
203
  # $IPR: webrick.rb,v 1.12 2002/10/01 17:16:31 gotoyuzo Exp $
10
204
 
205
+ module WEBrick
206
+ end
207
+
11
208
  require 'webrick/compat.rb'
12
209
 
13
210
  require 'webrick/version.rb'
@@ -1,4 +1,4 @@
1
- #
1
+ #--
2
2
  # accesslog.rb -- Access log handling utilities
3
3
  #
4
4
  # Author: IPR -- Internet Programming with Ruby -- writers
@@ -8,20 +8,89 @@
8
8
  # $IPR: accesslog.rb,v 1.1 2002/10/01 17:16:32 gotoyuzo Exp $
9
9
 
10
10
  module WEBrick
11
+
12
+ ##
13
+ # AccessLog provides logging to various files in various formats.
14
+ #
15
+ # Multiple logs may be written to at the same time:
16
+ #
17
+ # access_log = [
18
+ # [$stderr, WEBrick::AccessLog::COMMON_LOG_FORMAT],
19
+ # [$stderr, WEBrick::AccessLog::REFERER_LOG_FORMAT],
20
+ # ]
21
+ #
22
+ # server = WEBrick::HTTPServer.new :AccessLog => access_log
23
+ #
24
+ # Custom log formats may be defined. WEBrick::AccessLog provides a subset
25
+ # of the formatting from Apache's mod_log_config
26
+ # http://httpd.apache.org/docs/mod/mod_log_config.html#formats. See
27
+ # AccessLog::setup_params for a list of supported options
28
+
11
29
  module AccessLog
30
+
31
+ ##
32
+ # Raised if a parameter such as %e, %i, %o or %n is used without fetching
33
+ # a specific field.
34
+
12
35
  class AccessLogError < StandardError; end
13
36
 
37
+ ##
38
+ # The Common Log Format's time format
39
+
14
40
  CLF_TIME_FORMAT = "[%d/%b/%Y:%H:%M:%S %Z]"
41
+
42
+ ##
43
+ # Common Log Format
44
+
15
45
  COMMON_LOG_FORMAT = "%h %l %u %t \"%r\" %s %b"
46
+
47
+ ##
48
+ # Short alias for Common Log Format
49
+
16
50
  CLF = COMMON_LOG_FORMAT
51
+
52
+ ##
53
+ # Referer Log Format
54
+
17
55
  REFERER_LOG_FORMAT = "%{Referer}i -> %U"
56
+
57
+ ##
58
+ # User-Agent Log Format
59
+
18
60
  AGENT_LOG_FORMAT = "%{User-Agent}i"
61
+
62
+ ##
63
+ # Combined Log Format
64
+
19
65
  COMBINED_LOG_FORMAT = "#{CLF} \"%{Referer}i\" \"%{User-agent}i\""
20
66
 
21
67
  module_function
22
68
 
23
- # This format specification is a subset of mod_log_config of Apache.
24
- # http://httpd.apache.org/docs/mod/mod_log_config.html#formats
69
+ # This format specification is a subset of mod_log_config of Apache:
70
+ #
71
+ # %a:: Remote IP address
72
+ # %b:: Total response size
73
+ # %e{variable}:: Given variable in ENV
74
+ # %f:: Response filename
75
+ # %h:: Remote host name
76
+ # %{header}i:: Given request header
77
+ # %l:: Remote logname, always "-"
78
+ # %m:: Request method
79
+ # %{attr}n:: Given request attribute from <tt>req.attributes</tt>
80
+ # %{header}o:: Given response header
81
+ # %p:: Server's request port
82
+ # %{format}p:: The canonical port of the server serving the request or the
83
+ # actual port or the client's actual port. Valid formats are
84
+ # canonical, local or remote.
85
+ # %q:: Request query string
86
+ # %r:: First line of the request
87
+ # %s:: Request status
88
+ # %t:: Time the request was recieved
89
+ # %T:: Time taken to process the request
90
+ # %u:: Remote user from auth
91
+ # %U:: Unparsed URI
92
+ # %%:: Literal %
93
+
25
94
  def setup_params(config, req, res)
26
95
  params = Hash.new("")
27
96
  params["a"] = req.peeraddr[3]
@@ -46,6 +115,10 @@ module WEBrick
46
115
  params
47
116
  end
48
117
 
118
+ ##
119
+ # Formats +params+ according to +format_string+ which is described in
120
+ # setup_params.
121
+
49
122
  def format(format_string, params)
50
123
  format_string.gsub(/\%(?:\{(.*?)\})?>?([a-zA-Z%])/){
51
124
  param, spec = $1, $2
@@ -53,15 +126,33 @@ module WEBrick
53
126
  when ?e, ?i, ?n, ?o
54
127
  raise AccessLogError,
55
128
  "parameter is required for \"#{spec}\"" unless param
56
- params[spec][param] || "-"
129
+ (param = params[spec][param]) ? escape(param) : "-"
57
130
  when ?t
58
131
  params[spec].strftime(param || CLF_TIME_FORMAT)
132
+ when ?p
133
+ case param
134
+ when 'remote'
135
+ escape(params["i"].peeraddr[1].to_s)
136
+ else
137
+ escape(params["p"].to_s)
138
+ end
59
139
  when ?%
60
140
  "%"
61
141
  else
62
- params[spec]
142
+ escape(params[spec].to_s)
63
143
  end
64
144
  }
65
145
  end
146
+
147
+ ##
148
+ # Escapes control characters in +data+
149
+
150
+ def escape(data)
151
+ if data.tainted?
152
+ data.gsub(/[[:cntrl:]\\]+/) {$&.dump[1...-1]}.untaint
153
+ else
154
+ data
155
+ end
156
+ end
66
157
  end
67
158
  end
@@ -5,7 +5,7 @@
5
5
  # Copyright (c) 2003 Internet Programming with Ruby writers. All rights
6
6
  # reserved.
7
7
  #
8
- # $Id: cgi.rb 11708 2007-02-12 23:01:19Z shyouhei $
8
+ # $Id$
9
9
 
10
10
  require "webrick/httprequest"
11
11
  require "webrick/httpresponse"
@@ -13,10 +13,44 @@ require "webrick/config"
13
13
  require "stringio"
14
14
 
15
15
  module WEBrick
16
+
17
+ # A CGI library using WEBrick requests and responses.
18
+ #
19
+ # Example:
20
+ #
21
+ # class MyCGI < WEBrick::CGI
22
+ # def do_GET req, res
23
+ # res.body = 'it worked!'
24
+ # res.status = 200
25
+ # end
26
+ # end
27
+ #
28
+ # MyCGI.new.start
29
+
16
30
  class CGI
31
+
32
+ # The CGI error exception class
33
+
17
34
  CGIError = Class.new(StandardError)
18
35
 
19
- attr_reader :config, :logger
36
+ ##
37
+ # The CGI configuration. This is based on WEBrick::Config::HTTP
38
+
39
+ attr_reader :config
40
+
41
+ ##
42
+ # The CGI logger
43
+
44
+ attr_reader :logger
45
+
46
+ ##
47
+ # Creates a new CGI interface.
48
+ #
49
+ # The first argument in +args+ is a configuration hash which would update
50
+ # WEBrick::Config::HTTP.
51
+ #
52
+ # Any remaining arguments are stored in the <code>@options</code> instance
53
+ # variable for use by a subclass.
20
54
 
21
55
  def initialize(*args)
22
56
  if defined?(MOD_RUBY)
@@ -41,10 +75,17 @@ module WEBrick
41
75
  @options = args
42
76
  end
43
77
 
78
+ ##
79
+ # Reads +key+ from the configuration
80
+
44
81
  def [](key)
45
82
  @config[key]
46
83
  end
47
84
 
85
+ ##
86
+ # Starts the CGI process with the given environment +env+ and standard
87
+ # input and output +stdin+ and +stdout+.
88
+
48
89
  def start(env=ENV, stdin=$stdin, stdout=$stdout)
49
90
  sock = WEBrick::CGI::Socket.new(@config, env, stdin, stdout)
50
91
  req = HTTPRequest.new(@config)
@@ -77,7 +118,7 @@ module WEBrick
77
118
  res.set_error(ex)
78
119
  rescue HTTPStatus::Status => ex
79
120
  res.status = ex.code
80
- rescue Exception => ex
121
+ rescue Exception => ex
81
122
  @logger.error(ex)
82
123
  res.set_error(ex, true)
83
124
  ensure
@@ -108,6 +149,10 @@ module WEBrick
108
149
  end
109
150
  end
110
151
 
152
+ ##
153
+ # Services the request +req+ which will fill in the response +res+. See
154
+ # WEBrick::HTTPServlet::AbstractServlet#service for details.
155
+
111
156
  def service(req, res)
112
157
  method_name = "do_" + req.request_method.gsub(/-/, "_")
113
158
  if respond_to?(method_name)
@@ -118,11 +163,14 @@ module WEBrick
118
163
  end
119
164
  end
120
165
 
121
- class Socket
166
+ ##
167
+ # Provides HTTP socket emulation from the CGI environment
168
+
169
+ class Socket # :nodoc:
122
170
  include Enumerable
123
171
 
124
172
  private
125
-
173
+
126
174
  def initialize(config, env, stdin, stdout)
127
175
  @config = config
128
176
  @env = env
@@ -130,7 +178,7 @@ module WEBrick
130
178
  @body_part = stdin
131
179
  @out_port = stdout
132
180
  @out_port.binmode
133
-
181
+
134
182
  @server_addr = @env["SERVER_ADDR"] || "0.0.0.0"
135
183
  @server_name = @env["SERVER_NAME"]
136
184
  @server_port = @env["SERVER_PORT"]
@@ -143,7 +191,7 @@ module WEBrick
143
191
  setup_header
144
192
  @header_part << CRLF
145
193
  @header_part.rewind
146
- rescue Exception => ex
194
+ rescue Exception
147
195
  raise CGIError, "invalid CGI environment"
148
196
  end
149
197
  end
@@ -164,43 +212,42 @@ module WEBrick
164
212
  httpv = @config[:HTTPVersion]
165
213
  return "#{meth} #{url} HTTP/#{httpv}"
166
214
  end
167
-
215
+
168
216
  def setup_header
169
- add_header("CONTENT_TYPE", "Content-Type")
170
- add_header("CONTENT_LENGTH", "Content-length")
171
- @env.each_key{|name|
172
- if /^HTTP_(.*)/ =~ name
173
- add_header(name, $1.gsub(/_/, "-"))
217
+ @env.each{|key, value|
218
+ case key
219
+ when "CONTENT_TYPE", "CONTENT_LENGTH"
220
+ add_header(key.gsub(/_/, "-"), value)
221
+ when /^HTTP_(.*)/
222
+ add_header($1.gsub(/_/, "-"), value)
174
223
  end
175
224
  }
176
225
  end
177
-
178
- def add_header(envname, hdrname)
179
- if value = @env[envname]
180
- unless value.empty?
181
- @header_part << hdrname << ": " << value << CRLF
182
- end
226
+
227
+ def add_header(hdrname, value)
228
+ unless value.empty?
229
+ @header_part << hdrname << ": " << value << CRLF
183
230
  end
184
231
  end
185
232
 
186
233
  def input
187
234
  @header_part.eof? ? @body_part : @header_part
188
235
  end
189
-
236
+
190
237
  public
191
-
238
+
192
239
  def peeraddr
193
240
  [nil, @remote_port, @remote_host, @remote_addr]
194
241
  end
195
-
242
+
196
243
  def addr
197
244
  [nil, @server_port, @server_name, @server_addr]
198
245
  end
199
-
200
- def gets(eol=LF)
201
- input.gets(eol)
246
+
247
+ def gets(eol=LF, size=nil)
248
+ input.gets(eol, size)
202
249
  end
203
-
250
+
204
251
  def read(size=nil)
205
252
  input.read(size)
206
253
  end
@@ -208,7 +255,11 @@ module WEBrick
208
255
  def each
209
256
  input.each{|line| yield(line) }
210
257
  end
211
-
258
+
259
+ def eof?
260
+ input.eof?
261
+ end
262
+
212
263
  def <<(data)
213
264
  @out_port << data
214
265
  end
@@ -253,5 +304,5 @@ module WEBrick
253
304
  end
254
305
  end
255
306
  end
256
- end
257
- end
307
+ end
308
+ end