Splits the real download procedure from the download_url_to_tempfileobj and put it into a new function. this makes the download_url_to_tempfileobj clearer and more modular
Merge code from @zhengyuyu which makes a function more readable.

His code splits tuf.download.download_url_to_tempfileobj into two major
pieces. The first piece opens a connection to a URL, and computes
the required and reported lengths for downloading data from that given
URL. The second piece downloads data from the given URL in such a way
that we can defend against endless data and slow retrieval attacks.