Module: ActionDispatch::Http::Multipart

Defined in:
runtime/action_dispatch/multipart.rbs,
runtime/action_dispatch/multipart.rb

Defined Under Namespace

Classes: Form

Class Method Summary collapse

Class Method Details

.add_part(form, headers, content) ⇒ void

register one part: its name, whether it is a file, and its bytes. The header block is small and ASCII, so character ops are byte ops there.

Parameters:

  • form (Form) —

    the parsed form to add the part to

  • headers (String) —

    the part's header block, CRLF-separated

  • content (String) —

    the part's bytes



186
# File 'runtime/action_dispatch/multipart.rb', line 186

def self.add_part: (ActionDispatch::Http::Multipart::Form form, String headers, String content) -> void

.boundary(content_type) ⇒ String

the boundary parameter of a multipart/form-data; boundary=… header, unquoted.

Parameters:

  • content_type (String) —

    the request's Content-Type header value

Returns:

  • (String) —

    the boundary, or "" when the header has none



112
# File 'runtime/action_dispatch/multipart.rb', line 112

def self.boundary: (String content_type) -> String

.disposition_param(header, attr) ⇒ String

the value of <attr>="…" inside a Content-Disposition header.

Parameters:

  • header (String) —

    the Content-Disposition header value

  • attr (String) —

    the parameter name to read

Returns:

  • (String) —

    the value, or "" when it is absent



130
# File 'runtime/action_dispatch/multipart.rb', line 130

def self.disposition_param: (String header, String attr) -> String

.parse(body, content_type) ⇒ Form?

the parts of one multipart body, split into Form#fields (text) and Form#files. A body that does not parse answers nil instead of the parts found before it stopped: a missing boundary, a lost delimiter, or a truncated part means the payload never arrived whole, and the fields before the break are not the request the client meant. The caller turns nil into a request failure rather than serving half a form.

Parameters:

  • body (String) —

    the raw request body

  • content_type (String) —

    the Content-Type header, boundary included

Returns:

  • (Form, nil) —

    the parsed parts; nil when the body does not parse



150
# File 'runtime/action_dispatch/multipart.rb', line 150

def self.parse: (String body, String content_type) -> ActionDispatch::Http::Multipart::Form?