def parse_multipart_form(body, boundary):
files = RequestParameters()<EOL>fields = RequestParameters()<EOL>form_parts = body.split(boundary)<EOL>for form_part in form_parts[<NUM_LIT:1>:-<NUM_LIT:1>]:<EOL><INDENT>file_name = None<EOL>file_type = None<EOL>field_name = None<EOL>line_index = <NUM_LIT:2><EOL>line_end_index = <NUM_LIT:0><EOL>while not line_end_index == -<NUM_LIT:1>:<EOL><INDENT>line_end_index = form_part.find(b'<STR_LIT:\r\n>', line_index)<EOL>form_line = form_part[line_index:line_end_index].decode('<STR_LIT:utf-8>')<EOL>line_index = line_end_index + <NUM_LIT:2><EOL>if not form_line:<EOL><INDENT>break<EOL><DEDENT>colon_index = form_line.index('<STR_LIT::>')<EOL>form_header_field = form_line[<NUM_LIT:0>:colon_index].lower()<EOL>form_header_value, form_parameters = parse_header(<EOL>form_line[colon_index + <NUM_LIT:2>:])<EOL>if form_header_field == '<STR_LIT>':<EOL><INDENT>if '<STR_LIT:filename>' in form_parameters:<EOL><INDENT>file_name = form_parameters['<STR_LIT:filename>']<EOL><DEDENT>field_name = form_parameters.get('<STR_LIT:name>')<EOL><DEDENT>elif form_header_field == '<STR_LIT>':<EOL><INDENT>file_type = form_header_value<EOL><DEDENT><DEDENT>post_data = form_part[line_index:-<NUM_LIT:4>]<EOL>if file_name or file_type:<EOL><INDENT>file = File(type=file_type, name=file_name, body=post_data)<EOL>if field_name in files:<EOL><INDENT>files[field_name].append(file)<EOL><DEDENT>else:<EOL><INDENT>files[field_name] = [file]<EOL><DEDENT><DEDENT>else:<EOL><INDENT>value = post_data.decode('<STR_LIT:utf-8>')<EOL>if field_name in fields:<EOL><INDENT>fields[field_name].append(value)<EOL><DEDENT>else:<EOL><INDENT>fields[field_name] = [value]<EOL><DEDENT><DEDENT><DEDENT>return fields, files<EOL>
Parse a request body and returns fields and files

    :param body: bytes request body
    :param boundary: bytes multipart boundary
    :return: fields (RequestParameters), files (RequestParameters)