MCPcopy
hub / github.com/encode/httpx / download_response

Function download_response

httpx/_main.py:251–270  ·  httpx/_main.py::download_response
(response: Response, download: typing.BinaryIO)

Source from the content-addressed store, hash-verified

249
250
251def download_response(response: Response, download: typing.BinaryIO) -> None:
252 console = rich.console.Console()
253 console.print()
254 content_length = response.headers.get(class="st">"Content-Length")
255 with rich.progress.Progress(
256 class="st">"[progress.description]{task.description}",
257 class="st">"[progress.percentage]{task.percentage:>3.0f}%",
258 rich.progress.BarColumn(bar_width=None),
259 rich.progress.DownloadColumn(),
260 rich.progress.TransferSpeedColumn(),
261 ) as progress:
262 description = fclass="st">"Downloading [bold]{rich.markup.escape(download.name)}"
263 download_task = progress.add_task(
264 description,
265 total=int(content_length or 0),
266 start=content_length is not None,
267 )
268 for chunk in response.iter_bytes():
269 download.write(chunk)
270 progress.update(download_task, completed=response.num_bytes_downloaded)
271
272
273def validate_json(

Callers 1

mainFunction · 0.85

Calls 3

iter_bytesMethod · 0.80
getMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected