Module: Rack::Multipart
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Exceptions:
| |
Defined in: | lib/rack/multipart.rb, lib/rack/multipart/generator.rb, lib/rack/multipart/parser.rb, lib/rack/multipart/uploaded_file.rb |
Overview
A multipart form data parser, adapted from IOWA.
Usually, Rack::Request#POST
takes care of calling this.
Constant Summary
-
EOL =
# File 'lib/rack/multipart/parser.rb', line 33"\r\n"
-
Error =
Prefer to use the
Multipart::BoundaryTooLongError
class orBadRequest
.BoundaryTooLongError
-
MULTIPART =
# File 'lib/rack/multipart/parser.rb', line 34%r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|ni
-
MULTIPART_BOUNDARY =
# File 'lib/rack/multipart.rb', line 16"AaB03x"
-
MULTIPART_CONTENT_DISPOSITION =
# File 'lib/rack/multipart/parser.rb', line 36/Content-Disposition:(.*)(?=#{EOL}(\S|\z))/ni
-
MULTIPART_CONTENT_ID =
# File 'lib/rack/multipart/parser.rb', line 37/Content-ID:[ \t]*([^#{EOL}]*)/ni
-
MULTIPART_CONTENT_TYPE =
# File 'lib/rack/multipart/parser.rb', line 35/Content-Type:[ \t]*(.*)#{EOL}/ni
Class Method Summary
Class Method Details
.build_multipart(params, first = true)
[ GitHub ].extract_multipart(request, params = Rack::Utils.default_query_parser)
[ GitHub ]# File 'lib/rack/multipart.rb', line 68
def extract_multipart(request, params = Rack::Utils.default_query_parser) parse_multipart(request.env) end
.parse_multipart(env, params = Rack::Utils.default_query_parser)
[ GitHub ]# File 'lib/rack/multipart.rb', line 48
def parse_multipart(env, params = Rack::Utils.default_query_parser) unless io = env[RACK_INPUT] raise MissingInputError, "Missing input stream!" end if content_length = env['CONTENT_LENGTH'] content_length = content_length.to_i end content_type = env['CONTENT_TYPE'] tempfile = env[RACK_MULTIPART_TEMPFILE_FACTORY] || Parser::TEMPFILE_FACTORY bufsize = env[RACK_MULTIPART_BUFFER_SIZE] || Parser::BUFSIZE info = Parser.parse(io, content_length, content_type, tempfile, bufsize, params) env[RACK_TEMPFILES] = info.tmp_files return info.params end