aiohttp-zip-response 2.2.0__tar.gz → 2.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ * text=auto eol=lf
@@ -0,0 +1,30 @@
1
+ name: Lint
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ lint:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+
15
+ - name: Install uv
16
+ uses: astral-sh/setup-uv@v5
17
+ with:
18
+ enable-cache: true
19
+
20
+ - name: Set up Python
21
+ run: uv python install
22
+
23
+ - name: Install the project
24
+ run: uv sync --all-extras --dev
25
+
26
+ - name: Lint
27
+ run: |
28
+ uv run ruff check aiohttp_zip_response tests
29
+ uv run ruff format --diff aiohttp_zip_response tests
30
+ uv run mypy aiohttp_zip_response
@@ -0,0 +1,30 @@
1
+ name: "Publish"
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - v*
7
+
8
+ jobs:
9
+ run:
10
+ runs-on: ubuntu-latest
11
+ environment:
12
+ name: pypi
13
+ permissions:
14
+ id-token: write
15
+ contents: read
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v5
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v6
21
+ - name: Install Python 3.13
22
+ run: uv python install 3.13
23
+ - name: Build
24
+ run: uv build
25
+ - name: Smoke test (wheel)
26
+ run: uv run --isolated --no-project --with dist/*.whl tests/smoke_test.py
27
+ - name: Smoke test (source distribution)
28
+ run: uv run --isolated --no-project --with dist/*.tar.gz tests/smoke_test.py
29
+ - name: Publish
30
+ run: uv publish
@@ -0,0 +1,33 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - name: Install uv and set the python version
19
+ uses: astral-sh/setup-uv@v5
20
+ with:
21
+ enable-cache: true
22
+ python-version: ${{ matrix.python-version }}
23
+
24
+ - name: Install the project
25
+ run: uv sync --all-extras --dev
26
+
27
+ - name: Run tests and collect coverage
28
+ run: uv run pytest -vv --cov=aiohttp_zip_response --cov-report=xml
29
+
30
+ - name: Upload coverage reports to Codecov with GitHub Action
31
+ uses: codecov/codecov-action@v4
32
+ with:
33
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,7 @@
1
+ __pycache__
2
+ .mypy_cache
3
+ .pytest_cache
4
+ .ruff_cache
5
+ .coverage
6
+ build
7
+ dist
@@ -0,0 +1,11 @@
1
+ repos:
2
+ - repo: https://github.com/astral-sh/ruff-pre-commit
3
+ rev: v0.14.1
4
+ hooks:
5
+ - id: ruff
6
+ - id: ruff-format
7
+ args: [--check]
8
+ - repo: https://github.com/pre-commit/mirrors-mypy
9
+ rev: v1.18.2
10
+ hooks:
11
+ - id: mypy
@@ -0,0 +1 @@
1
+ 3.9
@@ -1,12 +1,14 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: aiohttp-zip-response
3
- Version: 2.2.0
3
+ Version: 2.4.0
4
4
  Summary: A AIOHTTP response class streaming a directory as ZIP archive
5
- Home-page: https://github.com/DoctorJohn/aiohttp-zip-response
5
+ Project-URL: homepage, https://github.com/DoctorJohn/aiohttp-zip-response
6
+ Project-URL: repository, https://github.com/DoctorJohn/aiohttp-zip-response
7
+ Project-URL: documentation, https://github.com/DoctorJohn/aiohttp-zip-response
8
+ Author-email: Jonathan Ehwald <github@ehwald.info>
6
9
  License: MIT
7
- Author: Jonathan Ehwald
8
- Author-email: github@ehwald.info
9
- Requires-Python: >=3.9,<4.0
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 5 - Production/Stable
10
12
  Classifier: Environment :: Web Environment
11
13
  Classifier: Intended Audience :: Developers
12
14
  Classifier: License :: OSI Approved :: MIT License
@@ -18,12 +20,14 @@ Classifier: Programming Language :: Python :: 3.10
18
20
  Classifier: Programming Language :: Python :: 3.11
19
21
  Classifier: Programming Language :: Python :: 3.12
20
22
  Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Programming Language :: Python :: 3.14
21
24
  Classifier: Topic :: Internet :: WWW/HTTP
22
25
  Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
23
- Requires-Dist: aiohttp (>=3.9.5,<4.0.0)
24
- Requires-Dist: stream-zip (>=0.0.81,<0.0.82)
25
- Project-URL: Documentation, https://github.com/DoctorJohn/aiohttp-zip-response
26
- Project-URL: Repository, https://github.com/DoctorJohn/aiohttp-zip-response
26
+ Classifier: Topic :: Software Development :: Libraries
27
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
28
+ Requires-Python: <4.0,>=3.9
29
+ Requires-Dist: aiohttp<4.0,>=3.9.5
30
+ Requires-Dist: stream-zip<0.1.0,>=0.0.83
27
31
  Description-Content-Type: text/markdown
28
32
 
29
33
  # AIOHTTP ZIP Response
@@ -34,13 +38,13 @@ Description-Content-Type: text/markdown
34
38
  [![License][license-image]][license-url]
35
39
 
36
40
  [versions-image]: https://img.shields.io/pypi/pyversions/aiohttp-zip-response
37
- [versions-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/master/setup.py
41
+ [versions-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/pyproject.toml
38
42
  [pypi-image]: https://img.shields.io/pypi/v/aiohttp-zip-response
39
43
  [pypi-url]: https://pypi.org/project/aiohttp-zip-response/
40
44
  [codecov-image]: https://codecov.io/gh/DoctorJohn/aiohttp-zip-response/branch/main/graph/badge.svg
41
45
  [codecov-url]: https://codecov.io/gh/DoctorJohn/aiohttp-zip-response
42
46
  [license-image]: https://img.shields.io/pypi/l/aiohttp-zip-response
43
- [license-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/master/LICENSE
47
+ [license-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/LICENSE
44
48
 
45
49
  A AIOHTTP response class streaming the contents of a directory as a ZIP archive.
46
50
  Thanks to [stream-zip](https://github.com/uktrade/stream-zip/), this works **without storing the entire ZIP in memory or disk**.
@@ -73,4 +77,3 @@ web.run_app(app)
73
77
 
74
78
  - The `Content-Length` header is not set because the size of the ZIP archive is not known in advance. This means clients such as browsers cannot display a download progress bar.
75
79
  - This package currently doesn't support streaming of symbolic links to directories.
76
-
@@ -6,13 +6,13 @@
6
6
  [![License][license-image]][license-url]
7
7
 
8
8
  [versions-image]: https://img.shields.io/pypi/pyversions/aiohttp-zip-response
9
- [versions-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/master/setup.py
9
+ [versions-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/pyproject.toml
10
10
  [pypi-image]: https://img.shields.io/pypi/v/aiohttp-zip-response
11
11
  [pypi-url]: https://pypi.org/project/aiohttp-zip-response/
12
12
  [codecov-image]: https://codecov.io/gh/DoctorJohn/aiohttp-zip-response/branch/main/graph/badge.svg
13
13
  [codecov-url]: https://codecov.io/gh/DoctorJohn/aiohttp-zip-response
14
14
  [license-image]: https://img.shields.io/pypi/l/aiohttp-zip-response
15
- [license-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/master/LICENSE
15
+ [license-url]: https://github.com/DoctorJohn/aiohttp-zip-response/blob/main/LICENSE
16
16
 
17
17
  A AIOHTTP response class streaming the contents of a directory as a ZIP archive.
18
18
  Thanks to [stream-zip](https://github.com/uktrade/stream-zip/), this works **without storing the entire ZIP in memory or disk**.
@@ -1,14 +1,14 @@
1
- [tool.poetry]
1
+ [project]
2
2
  name = "aiohttp-zip-response"
3
- version = "2.2.0"
3
+ version = "2.4.0"
4
4
  description = "A AIOHTTP response class streaming a directory as ZIP archive"
5
- authors = ["Jonathan Ehwald <github@ehwald.info>"]
6
- license = "MIT"
5
+ authors = [{ name = "Jonathan Ehwald", email = "github@ehwald.info" }]
6
+ license = { text = "MIT" }
7
7
  readme = "README.md"
8
- homepage = "https://github.com/DoctorJohn/aiohttp-zip-response"
9
- repository = "https://github.com/DoctorJohn/aiohttp-zip-response"
10
- documentation = "https://github.com/DoctorJohn/aiohttp-zip-response"
8
+ requires-python = ">=3.9,<4.0"
9
+ dependencies = ["aiohttp (>=3.9.5,<4.0)", "stream-zip (>=0.0.83,<0.1.0)"]
11
10
  classifiers = [
11
+ "Development Status :: 5 - Production/Stable",
12
12
  "Environment :: Web Environment",
13
13
  "Intended Audience :: Developers",
14
14
  "License :: OSI Approved :: MIT License",
@@ -20,32 +20,43 @@ classifiers = [
20
20
  "Programming Language :: Python :: 3.11",
21
21
  "Programming Language :: Python :: 3.12",
22
22
  "Programming Language :: Python :: 3.13",
23
+ "Programming Language :: Python :: 3.14",
23
24
  "Topic :: Internet :: WWW/HTTP",
24
25
  "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
26
+ "Topic :: Software Development :: Libraries",
27
+ "Topic :: Software Development :: Libraries :: Python Modules",
25
28
  ]
26
29
 
27
- [tool.poetry.dependencies]
28
- python = "^3.9"
29
- aiohttp = "^3.9.5"
30
- stream-zip = "^0.0.81"
30
+ [project.urls]
31
+ homepage = "https://github.com/DoctorJohn/aiohttp-zip-response"
32
+ repository = "https://github.com/DoctorJohn/aiohttp-zip-response"
33
+ documentation = "https://github.com/DoctorJohn/aiohttp-zip-response"
31
34
 
32
- [tool.poetry.group.dev.dependencies]
33
- pre-commit = "^4.0.1"
34
- pytest = "^8.2.2"
35
- pytest-cov = "^6.0.0"
36
- pytest-asyncio = "^0.24.0"
37
- pytest-aiohttp = "^1.0.5"
38
- pytest-randomly = "^3.15.0"
39
- ruff = "^0.7.3"
40
- mypy = "^1.10.1"
35
+ [build-system]
36
+ requires = ["hatchling"]
37
+ build-backend = "hatchling.build"
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "mypy>=1.15.0",
42
+ "pre-commit>=4.2.0",
43
+ "pytest>=8.3.5",
44
+ "pytest-aiohttp>=1.1.0",
45
+ "pytest-asyncio>=0.26.0",
46
+ "pytest-cov>=6.1.1",
47
+ "pytest-randomly>=3.16.0",
48
+ "ruff>=0.11.6",
49
+ ]
50
+
51
+ [tool.hatch.build.targets.wheel]
52
+ packages = ["aiohttp_zip_response"]
41
53
 
42
54
  [tool.ruff.lint]
43
55
  extend-select = ["I"]
44
56
 
45
57
  [tool.pytest.ini_options]
46
58
  asyncio_mode = "auto"
47
- addopts = "--cov=aiohttp_zip_response --cov-report term-missing"
59
+ addopts = "--cov=aiohttp_zip_response --cov-report term-missing --cov-report html"
48
60
 
49
- [build-system]
50
- requires = ["poetry-core"]
51
- build-backend = "poetry.core.masonry.api"
61
+ [tool.mypy]
62
+ check_untyped_defs = true
File without changes
@@ -0,0 +1,49 @@
1
+ import pytest
2
+ from aiohttp import web
3
+
4
+ from aiohttp_zip_response import ZipResponse
5
+
6
+
7
+ async def default_handler(request: web.Request) -> web.StreamResponse:
8
+ return ZipResponse(
9
+ request.query["path"],
10
+ )
11
+
12
+
13
+ async def custom_chunk_size_handler(request: web.Request) -> web.StreamResponse:
14
+ return ZipResponse(
15
+ request.query["path"],
16
+ chunk_size=256 * 1024,
17
+ )
18
+
19
+
20
+ async def custom_status_handler(request: web.Request) -> web.StreamResponse:
21
+ return ZipResponse(
22
+ request.query["path"],
23
+ status=418,
24
+ )
25
+
26
+
27
+ async def custom_reason_handler(request: web.Request) -> web.StreamResponse:
28
+ return ZipResponse(
29
+ request.query["path"],
30
+ reason="OKAY",
31
+ )
32
+
33
+
34
+ async def custom_headers_handler(request: web.Request) -> web.StreamResponse:
35
+ return ZipResponse(
36
+ request.query["path"],
37
+ headers={"X-TEST": "TEST"},
38
+ )
39
+
40
+
41
+ @pytest.fixture
42
+ async def cli(aiohttp_client):
43
+ app = web.Application()
44
+ app.router.add_get("/default/", default_handler)
45
+ app.router.add_get("/custom-chunk-size/", custom_chunk_size_handler)
46
+ app.router.add_get("/custom-status/", custom_status_handler)
47
+ app.router.add_get("/custom-reason/", custom_reason_handler)
48
+ app.router.add_get("/custom-headers/", custom_headers_handler)
49
+ return await aiohttp_client(app)
@@ -0,0 +1,11 @@
1
+ from aiohttp import web
2
+
3
+ from aiohttp_zip_response import ZipResponse
4
+
5
+
6
+ async def handle_zip(request):
7
+ return ZipResponse("path/to/directory")
8
+
9
+
10
+ app = web.Application()
11
+ app.router.add_get("/zip", handle_zip)
@@ -0,0 +1,271 @@
1
+ import os
2
+ import shutil
3
+ from io import BytesIO
4
+ from zipfile import ZipFile
5
+
6
+ import pytest
7
+
8
+
9
+ async def test_download_of_nested_dirs_and_files(tmp_path, cli):
10
+ file_path = tmp_path / "file.txt"
11
+ file_path.touch()
12
+
13
+ dir_path = tmp_path / "dir"
14
+ dir_path.mkdir()
15
+
16
+ nested_file_path = dir_path / "nested.txt"
17
+ nested_file_path.touch()
18
+
19
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
20
+ response.raise_for_status()
21
+
22
+ data = await response.read()
23
+ archive = ZipFile(BytesIO(data))
24
+
25
+ namelist = archive.namelist()
26
+ assert len(namelist) == 3
27
+ assert "file.txt" in namelist
28
+ assert "dir/" in namelist
29
+ assert "dir/nested.txt" in namelist
30
+
31
+ assert len(archive.filelist) == 3
32
+ assert archive.getinfo("dir/").is_dir()
33
+ assert not archive.getinfo("file.txt").is_dir()
34
+ assert not archive.getinfo("dir/nested.txt").is_dir()
35
+
36
+
37
+ async def test_download_of_single_dir(tmp_path, cli):
38
+ dir_path = tmp_path / "dir"
39
+ dir_path.mkdir()
40
+
41
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
42
+ response.raise_for_status()
43
+
44
+ data = await response.read()
45
+ archive = ZipFile(BytesIO(data))
46
+
47
+ namelist = archive.namelist()
48
+ assert len(namelist) == 1
49
+ assert "dir/" in namelist
50
+
51
+ assert len(archive.filelist) == 1
52
+ assert archive.getinfo("dir/").is_dir()
53
+
54
+
55
+ async def test_download_of_single_file(tmp_path, cli):
56
+ file_path = tmp_path / "file.txt"
57
+ file_path.touch()
58
+
59
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
60
+ response.raise_for_status()
61
+
62
+ data = await response.read()
63
+ archive = ZipFile(BytesIO(data))
64
+
65
+ namelist = archive.namelist()
66
+ assert len(namelist) == 1
67
+ assert "file.txt" in namelist
68
+
69
+ assert len(archive.filelist) == 1
70
+ assert not archive.getinfo("file.txt").is_dir()
71
+
72
+
73
+ @pytest.mark.skipif(shutil.which("unzip") is None, reason="Requires unzip")
74
+ async def test_download_of_a_file_symlink(tmp_path, cli):
75
+ file_path = tmp_path / "file.txt"
76
+ file_path.write_text("test")
77
+
78
+ link_path = tmp_path / "file-link"
79
+ link_path.symlink_to(file_path)
80
+
81
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
82
+ response.raise_for_status()
83
+
84
+ data = await response.read()
85
+ archive = ZipFile(BytesIO(data))
86
+
87
+ namelist = archive.namelist()
88
+ assert len(namelist) == 2
89
+ assert "file.txt" in namelist
90
+ assert "file-link" in namelist
91
+
92
+ archive_path = tmp_path / "archive.zip"
93
+ archive_path.write_bytes(data)
94
+
95
+ # Neither zipfile.TarFile.extractall nor shutil.unpack_archive extract symlinks
96
+ os.system(f"unzip -o {archive_path} -d {tmp_path / 'extracted'}")
97
+
98
+ extracted_file_path = tmp_path / "extracted" / "file.txt"
99
+ extracted_link_path = tmp_path / "extracted" / "file-link"
100
+ assert extracted_file_path.is_file()
101
+ assert extracted_link_path.is_symlink()
102
+ assert extracted_link_path.resolve() == extracted_file_path.resolve()
103
+
104
+
105
+ @pytest.mark.skipif(shutil.which("unzip") is None, reason="Requires unzip")
106
+ @pytest.mark.xfail(reason="Directory symlinks don't appear to be supported upstream")
107
+ async def test_download_of_a_directory_symlink(tmp_path, cli):
108
+ dir_path = tmp_path / "some-dir"
109
+ dir_path.mkdir()
110
+
111
+ link_path = tmp_path / "dir-link"
112
+ link_path.symlink_to(dir_path, target_is_directory=True)
113
+
114
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
115
+ response.raise_for_status()
116
+
117
+ data = await response.read()
118
+ archive = ZipFile(BytesIO(data))
119
+
120
+ namelist = archive.namelist()
121
+ assert len(namelist) == 2
122
+ assert "some-dir/" in namelist
123
+ assert "dir-link/" in namelist
124
+
125
+ archive_path = tmp_path / "archive.zip"
126
+ archive_path.write_bytes(data)
127
+
128
+ # Neither zipfile.TarFile.extractall nor shutil.unpack_archive extract symlinks
129
+ os.system(f"unzip -o {archive_path} -d {tmp_path / 'extracted'}")
130
+
131
+ extracted_dir_path = tmp_path / "extracted" / "some-dir"
132
+ extracted_link_path = tmp_path / "extracted" / "dir-link"
133
+ assert extracted_dir_path.is_dir()
134
+ assert extracted_link_path.is_symlink()
135
+ assert extracted_link_path.resolve() == extracted_dir_path.resolve()
136
+
137
+
138
+ async def test_directory_symlinks_are_not_included(tmp_path, cli):
139
+ dir_path = tmp_path / "some-dir"
140
+ dir_path.mkdir()
141
+
142
+ link_path = tmp_path / "dir-link"
143
+ link_path.symlink_to(dir_path, target_is_directory=True)
144
+
145
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
146
+ response.raise_for_status()
147
+
148
+ data = await response.read()
149
+ archive = ZipFile(BytesIO(data))
150
+
151
+ assert len(archive.filelist) == 1
152
+ assert archive.getinfo("some-dir/").is_dir()
153
+
154
+
155
+ async def test_empty_directory_results_in_empty_archive(tmp_path, cli):
156
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
157
+ response.raise_for_status()
158
+
159
+ data = await response.read()
160
+ archive = ZipFile(BytesIO(data))
161
+
162
+ namelist = archive.namelist()
163
+ assert len(namelist) == 0
164
+
165
+
166
+ async def test_nonexistent_path_results_in_empty_archive(tmp_path, cli):
167
+ nonexisting_path = tmp_path / "nonexistent"
168
+
169
+ response = await cli.get("/default/", params={"path": str(nonexisting_path)})
170
+ response.raise_for_status()
171
+
172
+ data = await response.read()
173
+ archive = ZipFile(BytesIO(data))
174
+
175
+ namelist = archive.namelist()
176
+ assert len(namelist) == 0
177
+
178
+
179
+ async def test_member_paths_are_relative(tmp_path, cli):
180
+ file_path = tmp_path / "file.txt"
181
+ file_path.touch()
182
+
183
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
184
+ response.raise_for_status()
185
+
186
+ data = await response.read()
187
+ archive = ZipFile(BytesIO(data))
188
+
189
+ namelist = archive.namelist()
190
+ assert len(namelist) == 1
191
+ assert str(file_path.absolute()) not in namelist
192
+ assert str(file_path.relative_to(tmp_path)) in namelist
193
+
194
+
195
+ async def test_file_contents_are_preserved(tmp_path, cli):
196
+ file_path = tmp_path / "file.txt"
197
+ file_path.write_text("test")
198
+
199
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
200
+ response.raise_for_status()
201
+
202
+ data = await response.read()
203
+ archive = ZipFile(BytesIO(data))
204
+
205
+ with archive.open("file.txt") as file:
206
+ assert file.read() == b"test"
207
+
208
+
209
+ async def test_default_status_code(tmp_path, cli):
210
+ response = await cli.get("/default/", params={"path": str(tmp_path)})
211
+ assert response.status == 200
212
+
213
+
214
+ async def test_custom_chunk_size(tmp_path, cli):
215
+ file_path = tmp_path / "file.txt"
216
+ file_path.write_text("a" * 1024)
217
+
218
+ response = await cli.get("/custom-chunk-size/", params={"path": str(tmp_path)})
219
+ response.raise_for_status()
220
+
221
+ data = await response.read()
222
+ archive = ZipFile(BytesIO(data))
223
+
224
+ namelist = archive.namelist()
225
+ assert len(namelist) == 1
226
+ assert archive.getinfo("file.txt").file_size == 1024
227
+
228
+
229
+ async def test_custom_status_code(tmp_path, cli):
230
+ file_path = tmp_path / "file.txt"
231
+ file_path.touch()
232
+
233
+ response = await cli.get("/custom-status/", params={"path": str(tmp_path)})
234
+ assert response.status == 418
235
+
236
+ data = await response.read()
237
+ archive = ZipFile(BytesIO(data))
238
+
239
+ namelist = archive.namelist()
240
+ assert len(namelist) == 1
241
+ assert "file.txt" in namelist
242
+
243
+
244
+ async def test_custom_reason(tmp_path, cli):
245
+ file_path = tmp_path / "file.txt"
246
+ file_path.touch()
247
+
248
+ response = await cli.get("/custom-reason/", params={"path": str(tmp_path)})
249
+ assert response.reason == "OKAY"
250
+
251
+ data = await response.read()
252
+ archive = ZipFile(BytesIO(data))
253
+
254
+ namelist = archive.namelist()
255
+ assert len(namelist) == 1
256
+ assert "file.txt" in namelist
257
+
258
+
259
+ async def test_custom_headers(tmp_path, cli):
260
+ file_path = tmp_path / "file.txt"
261
+ file_path.touch()
262
+
263
+ response = await cli.get("/custom-headers/", params={"path": str(tmp_path)})
264
+ assert response.headers["X-TEST"] == "TEST"
265
+
266
+ data = await response.read()
267
+ archive = ZipFile(BytesIO(data))
268
+
269
+ namelist = archive.namelist()
270
+ assert len(namelist) == 1
271
+ assert "file.txt" in namelist