def download_task(url, headers, destination, download_type='<STR_LIT>'):
<EOL>bot.verbose("<STR_LIT>" % (download_type, url))<EOL>file_name = "<STR_LIT>" % (destination,<EOL>next(tempfile._get_candidate_names()))<EOL>tar_download = download(url, file_name, headers=headers)<EOL>try:<EOL><INDENT>shutil.move(tar_download, destination)<EOL><DEDENT>except Exception:<EOL><INDENT>msg = "<STR_LIT>" % tar_download<EOL>msg += "<STR_LIT>"<EOL>bot.error(msg)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>return destination<EOL>
download an image layer (.tar.gz) to a specified download folder.
       This task is done by using local versions of the same download functions
       that are used for the client.
       core stream/download functions of the parent client.

       Parameters
       ==========
       image_id: the shasum id of the layer, already determined to not exist
       repo_name: the image name (library/ubuntu) to retrieve
       download_folder: download to this folder. If not set, uses temp.