Stores multipart form data. FormData
objects are created when WEBrick::HTTPUtils.parse_form_data
is called.
Constants
No documentation available
No documentation available
Attributes
Read & Write
The name of the form data part
Read & Write
The filename of the form data part
Class Methods
::
lib/webrick/httputils.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/lib/webrick/httputils.rb, line 265
def initialize(*args)
@name = @filename = @next_data = nil
if args.empty?
@raw_header = []
@header = nil
super("")
else
@raw_header = EmptyRawHeader
@header = EmptyHeader
super(args.shift)
unless args.empty?
@next_data = self.class.new(*args)
end
end
end
Creates a new FormData
object.
args
is an Array of form data entries. One FormData
will be created for each entry.
This is called by WEBrick::HTTPUtils.parse_form_data
for you
Instance Methods
#
lib/webrick/httputils.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/lib/webrick/httputils.rb, line 298
def <<(str)
if @header
super
elsif str == CRLF
@header = HTTPUtils::parse_header(@raw_header.join)
if cd = self['content-disposition']
if /\s+name="(.*?)"/ =~ cd then @name = $1 end
if /\s+filename="(.*?)"/ =~ cd then @filename = $1 end
end
else
@raw_header << str
end
self
end
Adds str
to this FormData
which may be the body, a header or a header entry.
This is called by WEBrick::HTTPUtils.parse_form_data
for you
#
lib/webrick/httputils.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/lib/webrick/httputils.rb, line 284
def [](*key)
begin
@header[key[0].downcase].join(", ")
rescue StandardError, NameError
super
end
end
Retrieves the header at the first entry in key
lib/webrick/httputils.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/lib/webrick/httputils.rb, line 318
def append_data(data)
tmp = self
while tmp
unless tmp.next_data
tmp.next_data = data
break
end
tmp = tmp.next_data
end
self
end
Adds data
at the end of the chain of entries
This is called by WEBrick::HTTPUtils.parse_form_data
for you.
lib/webrick/httputils.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/lib/webrick/httputils.rb, line 333
def each_data
tmp = self
while tmp
next_data = tmp.next_data
yield(tmp)
tmp = next_data
end
end
Yields each entry in this FormData
#
lib/webrick/httputils.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/lib/webrick/httputils.rb, line 345
def list
ret = []
each_data{|data|
ret << data.to_s
}
ret
end
Returns all the FormData
as an Array
#
lib/webrick/httputils.rb
View on GitHub
# File tmp/rubies/ruby-2.4.10/lib/webrick/httputils.rb, line 361
def to_s
String.new(self)
end
This FormData’s body