Soup.Multipart¶
Fields¶
None
Methods¶
| class | new (mime_type) |
| class | new_from_message (headers, body) |
append_form_file (control_name, filename, content_type, body) |
|
append_form_string (control_name, data) |
|
append_part (headers, body) |
|
free () |
|
get_length () |
|
get_part (part) |
|
to_message (dest_headers, dest_body) |
Details¶
-
class
Soup.Multipart¶ Represents a multipart HTTP message body, parsed according to the syntax of RFC 2046. Of particular interest to HTTP are
multipart/byte-rangesandmultipart/form-data.Although the headers of a
Soup.Multipartbody part will contain the full headers from that body part, libsoup does not interpret them according to MIME rules. For example, each body part is assumed to have “binary” Content-Transfer-Encoding, even if its headers explicitly state otherwise. In other words, don’t try to useSoup.Multipartfor handling real MIME multiparts.New in version 2.26.
-
classmethod
new(mime_type)¶ Parameters: mime_type ( str) – the MIME type of the multipart to create.Returns: a new empty Soup.Multipartof the given mime_typeReturn type: Soup.MultipartCreates a new empty
Soup.Multipartwith a randomly-generated boundary string. Note that mime_type must be the full MIME type, including “multipart/”.New in version 2.26.
-
classmethod
new_from_message(headers, body)¶ Parameters: - headers (
Soup.MessageHeaders) – the headers of the HTTP message to parse - body (
Soup.MessageBody) – the body of the HTTP message to parse
Returns: a new
Soup.Multipart(orNoneif the message couldn’t be parsed or wasn’t multipart).Return type: Parses headers and body to form a new
Soup.MultipartNew in version 2.26.
- headers (
-
append_form_file(control_name, filename, content_type, body)¶ Parameters: Adds a new MIME part containing body to self, using “Content-Disposition: form-data”, as per the HTML forms specification. See
Soup.form_request_new_from_multipart() for more details.New in version 2.26.
-
append_form_string(control_name, data)¶ Parameters: Adds a new MIME part containing data to self, using “Content-Disposition: form-data”, as per the HTML forms specification. See
Soup.form_request_new_from_multipart() for more details.New in version 2.26.
-
append_part(headers, body)¶ Parameters: - headers (
Soup.MessageHeaders) – the MIME part headers - body (
Soup.Buffer) – the MIME part body
Adds a new MIME part to self with the given headers and body. (The multipart will make its own copies of headers and body, so you should free your copies if you are not using them for anything else.)
New in version 2.26.
- headers (
-
free()¶ Frees self
New in version 2.26.
-
get_length()¶ Returns: the number of body parts in self Return type: intGets the number of body parts in self
New in version 2.26.
-
get_part(part)¶ Parameters: part ( int) – the part number to get (counting from 0)Returns: Trueon success,Falseif part is out of range (in which case headers and body won’t be set)headers: return location for the MIME part headers body: return location for the MIME part body Return type: ( bool, headers:Soup.MessageHeaders, body:Soup.Buffer)Gets the indicated body part from self.
New in version 2.26.
-
to_message(dest_headers, dest_body)¶ Parameters: - dest_headers (
Soup.MessageHeaders) – the headers of the HTTP message to serialize self to - dest_body (
Soup.MessageBody) – the body of the HTTP message to serialize self to
Serializes self to dest_headers and dest_body.
New in version 2.26.
- dest_headers (
-
classmethod