<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def stream_directory(directory, recursive=False, patterns='**', chunk_size=default_chunk_size):
 """Gets a buffered generator for streaming directories. Returns a buffered generator which encodes a directory as :mimetype:`multipart/form-data` with the corresponding headers. Parameters directory : str The filepath of the directory to stream recursive : bool Stream all content within the directory recursively? patterns : str | list Single *glob* pattern or list of *glob* patterns and compiled regular expressions to match the names of the filepaths to keep chunk_size : int Maximum size of each stream chunk """

    stream = DirectoryStream(directory,
                             recursive=recursive,
                             patterns=patterns,
                             chunk_size=chunk_size)

    return stream.body(), stream.headers