Gets a buffered generator for streaming text.

    Returns a buffered generator which encodes a string as
    :mimetype:`multipart/form-data` with the corresponding headers.

    Parameters
    ----------
    text : str
        The data bytes to stream
    chunk_size : int
        The maximum size of each stream chunk

    Returns
    -------
        (generator, dict)

def stream_text(text, chunk_size=default_chunk_size):
    """Gets a buffered generator for streaming text.

    Returns a buffered generator which encodes a string as
    :mimetype:`multipart/form-data` with the corresponding headers.

    Parameters
    ----------
    text : str
        The data bytes to stream
    chunk_size : int
        The maximum size of each stream chunk

    Returns
    -------
        (generator, dict)
    """
    if isgenerator(text):
        def binary_stream():
            for item in text:
                if six.PY2 and isinstance(text, six.binary_type):
                    #PY2: Allow binary strings under Python 2 since
                    # Python 2 code is not expected to always get the
                    # distinction between text and binary strings right.
                    yield text
                else:
                    yield text.encode("utf-8")
        data = binary_stream()
    elif six.PY2 and isinstance(text, six.binary_type):
        #PY2: See above.
        data = text
    else:
        data = text.encode("utf-8")

    return stream_bytes(data, chunk_size)