Read data from ``reader`` and parse multipart/form-data fields.

    ``boundary`` is the multipart/form-data boundary.
    ``cb`` is a callable that will be called as ``cb(headers, reader)`` to
    handle the parsed field.

def parse_multipart_formdata(reader, boundary, cb):
    """Read data from ``reader`` and parse multipart/form-data fields.

    ``boundary`` is the multipart/form-data boundary.
    ``cb`` is a callable that will be called as ``cb(headers, reader)`` to
    handle the parsed field.
    """

    breader = BoundaryReader(reader, boundary)
    # The BoundaryReader expects a new line before the boundary string,
    # We make sure the new line exists
    breader.put(b'\r\n')
    # Clean up garbage before the first boundary
    _dummy_data = yield from breader.read()
    logger('parse_multipart_formdata').debug('_dummy_data = %r', _dummy_data)
    del _dummy_data

    breader = BoundaryReader(reader, boundary)
    line = yield from breader.readline()
    while line:
        headers = []
        while line.strip():
            header = parse_http_header(line)
            headers.append(header)
            line = yield from breader.readline()

        yield from cb(headers, breader)

        yield from breader.read()
        breader = BoundaryReader(reader, boundary)
        line = yield from breader.readline()