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.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