def http_download(url, download_file,<EOL>overwrite=False, raise_http_exception=True):
assert isinstance(url, (str, _oldstr))<EOL>assert isinstance(download_file, (str, _oldstr))<EOL>assert isinstance(overwrite, bool)<EOL>assert isinstance(raise_http_exception, bool)<EOL>u = urlparse.urlparse(url)<EOL>assert u.scheme in ['<STR_LIT:http>', '<STR_LIT>']<EOL>if os.path.isfile(download_file) and not overwrite:<EOL><INDENT>raise OSError('<STR_LIT>' % download_file)<EOL><DEDENT>r = requests.get(url, stream=True)<EOL>if raise_http_exception:<EOL><INDENT>r.raise_for_status()<EOL><DEDENT>if r.status_code == <NUM_LIT:200>:<EOL><INDENT>with open(download_file, '<STR_LIT:wb>') as fh:<EOL><INDENT>r.raw.decode_content = True<EOL>shutil.copyfileobj(r.raw, fh)<EOL><DEDENT>_logger.info('<STR_LIT>', download_file)<EOL><DEDENT>else:<EOL><INDENT>_logger.error('<STR_LIT>',<EOL>url, r.status_code, r.reason)<EOL><DEDENT>
Download a file over HTTP(S).

    See: http://stackoverflow.com/a/13137873/5651021 

    Parameters
    ----------
    url : str
        The URL.
    download_file : str
        The path of the local file to write to.
    overwrite : bool, optional
        Whether to overwrite an existing file (if present). [False]
    raise_http_exception : bool, optional
        Whether to raise an exception if there is an HTTP error. [True]

    Raises
    ------
    OSError
        If the file already exists and overwrite is set to False.
    `requests.HTTPError`
        If an HTTP error occurred and `raise_http_exception` was set to `True`.