Minor cleanup to improve hash use
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
8c3f13f98d
commit
36ed53ff93
@ -426,7 +426,7 @@ class CGI
|
|||||||
raise EOFError.new("no content body") unless status
|
raise EOFError.new("no content body") unless status
|
||||||
raise EOFError.new("bad content body") unless first_line == status
|
raise EOFError.new("bad content body") unless first_line == status
|
||||||
## parse and set params
|
## parse and set params
|
||||||
params = {}
|
params = Hash.new { |h,k| h[k] = [] }
|
||||||
@files = {}
|
@files = {}
|
||||||
boundary_rexp = /--#{Regexp.quote(boundary)}(#{EOL}|--)/
|
boundary_rexp = /--#{Regexp.quote(boundary)}(#{EOL}|--)/
|
||||||
boundary_size = "#{EOL}--#{boundary}#{EOL}".bytesize
|
boundary_size = "#{EOL}--#{boundary}#{EOL}".bytesize
|
||||||
@ -496,7 +496,7 @@ class CGI
|
|||||||
name = $1 || $2 || ''
|
name = $1 || $2 || ''
|
||||||
if body.original_filename.empty?
|
if body.original_filename.empty?
|
||||||
value=body.read.dup.force_encoding(@accept_charset)
|
value=body.read.dup.force_encoding(@accept_charset)
|
||||||
(params[name] ||= []) << value
|
params[name] << value
|
||||||
unless value.valid_encoding?
|
unless value.valid_encoding?
|
||||||
if @accept_charset_error_block
|
if @accept_charset_error_block
|
||||||
@accept_charset_error_block.call(name,value)
|
@accept_charset_error_block.call(name,value)
|
||||||
@ -510,7 +510,7 @@ class CGI
|
|||||||
define_method(:content_type){""}
|
define_method(:content_type){""}
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
(params[name] ||= []) << body
|
params[name] << body
|
||||||
@files[name]=body
|
@files[name]=body
|
||||||
end
|
end
|
||||||
## break loop
|
## break loop
|
||||||
@ -518,7 +518,6 @@ class CGI
|
|||||||
break if content_length == -1
|
break if content_length == -1
|
||||||
end
|
end
|
||||||
raise EOFError, "bad boundary end of body part" unless boundary_end =~ /--/
|
raise EOFError, "bad boundary end of body part" unless boundary_end =~ /--/
|
||||||
params.default = []
|
|
||||||
params
|
params
|
||||||
end # read_multipart
|
end # read_multipart
|
||||||
private :read_multipart
|
private :read_multipart
|
||||||
|
Loading…
x
Reference in New Issue
Block a user