download

gonto.download.http_get(url: str, destination: str | Path, allow_overwrite: bool = False, callback: Callable[[float], None] | None = None) None

Download a file using HTTP protocol.

Note

The progress passed to callback function may stay to 0 during all the download. This occurs if the HTTP server does not provide the Content-Length.

Parameters:
  • url – The URL of the file to download.

  • destination – The path of the destination file.

  • allow_overwrite – Allow to overwrite existing files (default: False).

  • callback

    A callable to track download progress (default: None).

    Callback definition:

    def callback(progress: float) -> None:
        pass
    

Raises:
  • FileExistsError – If the output file already exists and allow_overwrite is False.

  • IOError – If the download was incomplete or if server sent more bytes than expected.