Module: Rack::Multipart

Defined in:
lib/rack/multipart.rb,
lib/rack/multipart/parser.rb,
lib/rack/multipart/generator.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.

Defined Under Namespace

Classes: Generator, MultipartPartLimitError, Parser, UploadedFile

Constant Summary collapse

EOL =
"\r\n"
MULTIPART_BOUNDARY =
"AaB03x"
MULTIPART =
%r|\Amultipart/.*boundary=\"?([^\";,]+)\"?|ni
TOKEN =
/[^\s()<>,;:\\"\/\[\]?=]+/
CONDISP =
/Content-Disposition:\s*#{TOKEN}\s*/i
DISPPARM =
/;\s*(#{TOKEN})=("(?:\\"|[^"])*"|#{TOKEN})/
RFC2183 =
/^#{CONDISP}(#{DISPPARM})+$/i
BROKEN_QUOTED =
/^#{CONDISP}.*;\sfilename="(.*?)"(?:\s*$|\s*;\s*#{TOKEN}=)/i
BROKEN_UNQUOTED =
/^#{CONDISP}.*;\sfilename=(#{TOKEN})/i
MULTIPART_CONTENT_TYPE =
/Content-Type: (.*)#{EOL}/ni
MULTIPART_CONTENT_DISPOSITION =
/Content-Disposition:.*\s+name="?([^\";]*)"?/ni
MULTIPART_CONTENT_ID =
/Content-ID:\s*([^#{EOL}]*)/ni

Class Method Summary collapse

Class Method Details

.build_multipart(params, first = true) ⇒ Object



28
29
30
# File 'lib/rack/multipart.rb', line 28

def build_multipart(params, first = true)
  Generator.new(params, first).dump
end

.parse_multipart(env) ⇒ Object



24
25
26
# File 'lib/rack/multipart.rb', line 24

def parse_multipart(env)
  Parser.create(env).parse
end