Skip to content
Myr

docs: upload progress (#2725)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* upload progress * typo * typo * Update docs/advanced.md * Update advanced.md * Update docs/advanced.md Co-authored-by: Kar Petrosyan <92274156+karosis88@users.noreply.github.com> ---------

authored by Trim21 · committed by GitHub · parent 2c49a15 · Browse files · 1 file+32 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Co-authored-by: Tom Christie <tom@tomchristie.com>
  • Co-authored-by: Kar Petrosyan <92274156+karosis88@users.noreply.github.com>

Diff stats

1 file+32 added−0 removed

  • other:+32 added−0 removed

1 file+32 added−0 removed

modified:docs/advanced.md+32 added
424 unmodified lines
425```426427![rich progress bar](img/rich-progress.gif)428429## Monitoring upload progress430431If you need to monitor upload progress of large responses, you can use request content generator streaming.432433For example, showing a progress bar using the [`tqdm`](https://github.com/tqdm/tqdm) library.434435```python436import io437import random438439import httpx440from tqdm import tqdm441442443def gen():444 """445 this is a complete example with generated random bytes.446 you can replace `io.BytesIO` with real file object.447 """448 total = 32 * 1024 * 1024 # 32m449 with tqdm(ascii=True, unit_scale=True, unit='B', unit_divisor=1024, total=total) as bar:450 with io.BytesIO(random.randbytes(total)) as f:451 while data := f.read(1024):452 yield data453 bar.update(len(data))454455456httpx.post("https://httpbin.org/post", content=gen())457```458459![tqdm progress bar](img/tqdm-progress.gif)460461## .netrc Support462463HTTPX can be configured to use [a `.netrc` config file](https://everything.curl.dev/usingcurl/netrc) for authentication.464
832 unmodified lines