Metadata-Version: 2.1
Name: httpx-file
Version: 0.2.0
Summary: File transport adapter for httpx.
Home-page: https://github.com/nuno-andre/httpx-file#readme
Author: Nuno André
Author-email: mail@nunoand.re
License: BSD-3-Clause
Project-URL: Source, https://github.com/nuno-andre/httpx-file
Project-URL: Bug Tracker, https://github.com/nuno-andre/httpx-file/issues
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development
Classifier: Typing :: Typed
Requires-Python: >=3.6.1
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx (>=0.20)
Requires-Dist: aiofiles
Provides-Extra: dev
Requires-Dist: flake8 ; extra == 'dev'
Requires-Dist: pytest ; extra == 'dev'
Requires-Dist: pytest-asyncio ; extra == 'dev'
Requires-Dist: types-aiofiles ; extra == 'dev'

# httpx-file

Transport adapter fort __[httpx](https://github.com/encode/httpx)__ to allow
`file://` URI fetching in the local filesystem.


## Installation

<a href="https://pypi.org/project/httpx-file/"><pre>
pip install httpx-file
</pre></a>


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

```python
from httpx_file import Client

client = Client()
client.get('file:///etc/fstab)
```

Or you can also mount `FileTransport` in a `httpx.Client` instance.

```python
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'.

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

```python
from httpx_file import FileTransport
from httpx import AsyncClient

client = AsyncClient(mounts={'file://': FileTransport()})
client.get('file:///etc/fstab)
```
