File transport adapter for httpx.
Project description
httpx-file
Transport adapter fort httpx to allow
file:// URI fetching in the local filesystem.
Installation
pip install httpx-file
Usage
Synchronous
httpx-file subclasses httpx.Client, so you can just replace httpx.Client
with httpx_file.Client to get the same behavior with added file:// protocol
support.
from httpx_file import Client
client = Client()
client.get('file:///etc/fstab)
Or you can also mount FileTransport in a httpx.Client instance.
from httpx_file import FileTransport
from httpx import Client
client = Client(mounts={'file://': FileTransport()})
client.get('file:///etc/fstab)
Asynchronous
It is also possible to use httpx-file possibilities asynchronous way. To do this, you can just replace 'httpx.AsyncClient' with 'httpx_file.AsyncClient'.
from httpx_file import AsyncClient
# Taken from tests/test_transport.py
from pathlib import Path
THIS = Path(__file__)
async def test_async_client():
async_client = AsyncClient()
async_response = await async_client.get(THIS.as_uri())
assert async_response.content == THIS.read_bytes()
Or you can also mount FileTransport in a httpx.AsyncClient instance.
from httpx_file import FileTransport
from httpx import AsyncClient
client = AsyncClient(mounts={'file://': FileTransport()})
client.get('file:///etc/fstab)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file httpx-file-0.2.0.tar.gz.
File metadata
- Download URL: httpx-file-0.2.0.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a00f1dd02c9ffb5e7e072205c30f7ae0d867c397318b045a40b3268f2cdfa932
|
|
| MD5 |
8df2c67b3983c35d6360048969c2f78d
|
|
| BLAKE2b-256 |
b4f7737dbfaa3b3288ce69f75fad9a4cd22cae60d71763618ddd849018895172
|
File details
Details for the file httpx_file-0.2.0-py3-none-any.whl.
File metadata
- Download URL: httpx_file-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a425b351bf65aa394c02096204dc3fa8b647573a289079f927d3e3abfa3c7c8
|
|
| MD5 |
b8e6410b268ec1012490007c10fbe2f7
|
|
| BLAKE2b-256 |
f49c4f3fba4c1b5a8919c3f6d407a41df43980c6a03a631d49f458b9546da128
|