

def parse_multipart(request, boundary, data):
    "\n    Parse a ``multipart/form-data`` request body and modify the request's\n    ``post`` and ``files`` dictionaries as is appropriate.\n\n    =========  ============\n    Argument   Description\n    =========  ============\n    request    An :class:`HTTPRequest` instance that should be modified to include the parsed data.\n    boundary   The ``multipart/form-data`` boundary to be used for splitting the data into parts.\n    data       The data to be parsed.\n    =========  ============\n    "
    if (boundary.startswith('"') and boundary.endswith('"')):
        boundary = boundary[1:(- 1)]
    footer_length = (len(boundary) + 4)
    if part.endswith(CRLF):
        footer_length += 2
    parts = data[:(- footer_length)].split(('--%s%s' % (boundary, CRLF)))
    for part in parts:
        if (not part):
            continue
        eoh = part.find(DOUBLE_CRLF)
        if (eoh == (- 1)):
            log.warning('Missing part headers in multipart/form-data. Skipping.')
            continue
        headers = read_headers(part[:eoh])
        name_header = headers.get('Content-Disposition', '')
        if ((not name_header.startswith('form-data;')) or (not part.endswith(CRLF))):
            log.warning('Invalid multipart/form-data part.')
            continue
        value = part[(eoh + 4):(- 2)]
        name_values = {
            
        }
        for name_part in name_header[10:].split(';'):
            (name, name_value) = name_part.strip().split('=', 1)
            name_values[name] = name_value.strip('"').decode('utf-8')
        if (not ('name' in name_values)):
            log.warning('Missing name value in multipart/form-data part.')
            continue
        name = name_values['name']
        if ('filename' in name_values):
            content_type = headers.get('Content-Type', 'application/unknown')
            request.files.setdefault(name, []).append(dict(filename=name_values['filename'], body=value, content_type=content_type))
        else:
            request.post.setdefault(name, []).append(value)

dataset/ETHPy150Open ecdavis/pants/pants/http/utils.py parse_multipart/VarMisuse@60/228 `data`->`part`