diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cgi.rb | 9 | ||||
-rw-r--r-- | lib/ostruct.rb | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/lib/cgi.rb b/lib/cgi.rb index 463b17d98a..afc99ab7ca 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -770,7 +770,7 @@ class CGI # cookie1.domain = 'domain' # cookie1.expires = Time.now + 30 # cookie1.secure = true - class Cookie < SimpleDelegator + class Cookie < DelegateClass(Array) # Create a new CGI::Cookie object. # @@ -1012,10 +1012,13 @@ class CGI end c = if bufsize < content_length - stdinput.read(bufsize) or '' + stdinput.read(bufsize) else - stdinput.read(content_length) or '' + stdinput.read(content_length) end + if c.nil? + raise EOFError, "bad content body" + end buf.concat(c) content_length -= c.size end diff --git a/lib/ostruct.rb b/lib/ostruct.rb index 464fff0cdf..8d8484caf5 100644 --- a/lib/ostruct.rb +++ b/lib/ostruct.rb @@ -58,6 +58,13 @@ class OpenStruct @table = @table.dup end + def new_ostruct_member(name) + self.instance_eval %{ + def #{name}; @table[:#{name}]; end + def #{name}=(x); @table[:#{name}] = x; end + } + end + def method_missing(mid, *args) # :nodoc: mname = mid.id2name len = args.length @@ -70,6 +77,7 @@ class OpenStruct end mname.chop! @table[mname.intern] = args[0] + self.new_ostruct_member(mname) elsif len == 0 @table[mid] else |