fdroidserver.net module

fdroidserver.net.download_file(url, local_filename=None, dldir='tmp', retries=3, backoff_factor=0.1)

Try hard to download the file, including retrying on failures.

This has two retry cycles, one inside of the requests session, the other provided by this function. The requests retry logic applies to failed DNS lookups, socket connections and connection timeouts, never to requests where data has made it to the server. This handles ChunkedEncodingError during transfer in its own retry loop. This can result in more retries than are specified in the retries parameter.

fdroidserver.net.download_using_mirrors(mirrors, local_filename=None)

Try to download the file from any working mirror.

Download the file that all URLs in the mirrors list point to, trying all the tricks, starting with the most private methods first. The list of mirrors is converted into a list of mirror configurations to try, in order that the should be attempted.

This builds mirror_configs_to_try using all possible combos to try. If a mirror is marked with worksWithoutSNI: True, then this logic will try it twice: first without SNI, then again with SNI.

fdroidserver.net.http_get(url, etag=None, timeout=600)

Download the content from the given URL by making a GET request.

If an ETag is given, it will do a HEAD request first, to see if the content changed.

Parameters:
url

The URL to download from.

etag

The last ETag to be used for the request (optional).

Returns:
A tuple consisting of:
  • The raw content that was downloaded or None if it did not change

  • The new eTag as returned by the HTTP request