aboutsummaryrefslogtreecommitdiffstats
path: root/lib/webrick/httpstatus.rb
diff options
context:
space:
mode:
authorshyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-10 09:33:47 +0000
committershyouhei <shyouhei@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-01-10 09:33:47 +0000
commit73cd7b6697849b563a0154907b8a61c43e4ba209 (patch)
treec8889fa5acfcbb8ea726e55c39798dcce16a7741 /lib/webrick/httpstatus.rb
parent9982c9298c10395a64429db5d433aae0c893c265 (diff)
downloadruby-73cd7b6697849b563a0154907b8a61c43e4ba209.tar.gz
* lib/webrick/accesslog.rb : Escape needed.
* lib/webrick/httpstatus.rb : ditto. * lib/webrick/httprequest.rb : ditto. * lib/webrick/httputils.rb : ditto. * test/webrick/test_cgi.rb (TestWEBrickCGI::test_bad_): Test for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpstatus.rb')
-rw-r--r--lib/webrick/httpstatus.rb31
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/webrick/httpstatus.rb b/lib/webrick/httpstatus.rb
index d022ddb446..77a1d3ee50 100644
--- a/lib/webrick/httpstatus.rb
+++ b/lib/webrick/httpstatus.rb
@@ -12,7 +12,17 @@ module WEBrick
module HTTPStatus
- class Status < StandardError; end
+ class Status < StandardError
+ def initialize(message, *rest)
+ super(AccessLog.escape(message), *rest)
+ end
+ class << self
+ attr_reader :code, :reason_phrase
+ end
+ def code() self::class::code end
+ def reason_phrase() self::class::reason_phrase end
+ alias to_i code
+ end
class Info < Status; end
class Success < Status; end
class Redirect < Status; end
@@ -68,6 +78,7 @@ module WEBrick
CodeToError = {}
StatusMessage.each{|code, message|
+ message.freeze
var_name = message.gsub(/[ \-]/,'_').upcase
err_name = message.gsub(/[ \-]/,'')
@@ -79,18 +90,12 @@ module WEBrick
when 500...600; parent = ServerError
end
- eval %-
- RC_#{var_name} = #{code}
- class #{err_name} < #{parent}
- def self.code() RC_#{var_name} end
- def self.reason_phrase() StatusMessage[code] end
- def code() self::class::code end
- def reason_phrase() self::class::reason_phrase end
- alias to_i code
- end
- -
-
- CodeToError[code] = const_get(err_name)
+ const_set("RC_#{var_name}", code)
+ err_class = Class.new(parent)
+ err_class.instance_variable_set(:@code, code)
+ err_class.instance_variable_set(:@reason_phrase, message)
+ const_set(err_name, err_class)
+ CodeToError[code] = err_class
}
def reason_phrase(code)