hishel 1.1.3__tar.gz → 1.1.4__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.
- {hishel-1.1.3 → hishel-1.1.4}/CHANGELOG.md +12 -1
- {hishel-1.1.3 → hishel-1.1.4}/PKG-INFO +13 -2
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_async_httpx.py +14 -2
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/_storages/_async_sqlite.py +5 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/_storages/_sync_sqlite.py +5 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_sync_httpx.py +14 -2
- {hishel-1.1.3 → hishel-1.1.4}/hishel/requests.py +7 -2
- {hishel-1.1.3 → hishel-1.1.4}/pyproject.toml +1 -1
- {hishel-1.1.3 → hishel-1.1.4}/.gitignore +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/LICENSE +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/README.md +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/__init__.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_async_cache.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/_headers.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/_spec.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/_storages/_async_base.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/_storages/_packing.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/_storages/_sync_base.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_core/models.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_policies.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_sync_cache.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/_utils.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/asgi.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/fastapi.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/httpx.py +0 -0
- {hishel-1.1.3 → hishel-1.1.4}/hishel/py.typed +0 -0
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
## What's Changed in 1.1.4
|
|
2
|
+
### 🐛 Bug Fixes
|
|
3
|
+
|
|
4
|
+
* don't raise an error on consumed streams that were read into memory by @karpetrosyan
|
|
5
|
+
* close sqlite connections properly by @karpetrosyan
|
|
6
|
+
|
|
7
|
+
### Contributors
|
|
8
|
+
* @karpetrosyan
|
|
9
|
+
|
|
10
|
+
**Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.3...1.1.4
|
|
11
|
+
|
|
1
12
|
## What's Changed in 1.1.3
|
|
2
13
|
### ⚙️ Miscellaneous Tasks
|
|
3
14
|
|
|
@@ -8,9 +19,9 @@
|
|
|
8
19
|
* fix: set `after_revalidation=True` for `NeedsToBeUpdated` -> `FromCache` transition by @jlopex in [#402](https://github.com/karpetrosyan/hishel/pull/402)
|
|
9
20
|
|
|
10
21
|
### Contributors
|
|
22
|
+
* @karpetrosyan
|
|
11
23
|
* @martinblech
|
|
12
24
|
* @jlopex
|
|
13
|
-
* @karpetrosyan
|
|
14
25
|
|
|
15
26
|
**Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.2...1.1.3
|
|
16
27
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hishel
|
|
3
|
-
Version: 1.1.
|
|
3
|
+
Version: 1.1.4
|
|
4
4
|
Summary: Elegant HTTP Caching for Python
|
|
5
5
|
Project-URL: Homepage, https://hishel.com
|
|
6
6
|
Project-URL: Source, https://github.com/karpetrosyan/hishel
|
|
@@ -406,6 +406,17 @@ Hishel is inspired by and builds upon the excellent work in the Python HTTP ecos
|
|
|
406
406
|
<strong>Made with ❤️ by <a href="https://github.com/karpetrosyan">Kar Petrosyan</a></strong>
|
|
407
407
|
</p>
|
|
408
408
|
|
|
409
|
+
## What's Changed in 1.1.4
|
|
410
|
+
### 🐛 Bug Fixes
|
|
411
|
+
|
|
412
|
+
* don't raise an error on consumed streams that were read into memory by @karpetrosyan
|
|
413
|
+
* close sqlite connections properly by @karpetrosyan
|
|
414
|
+
|
|
415
|
+
### Contributors
|
|
416
|
+
* @karpetrosyan
|
|
417
|
+
|
|
418
|
+
**Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.3...1.1.4
|
|
419
|
+
|
|
409
420
|
## What's Changed in 1.1.3
|
|
410
421
|
### ⚙️ Miscellaneous Tasks
|
|
411
422
|
|
|
@@ -416,9 +427,9 @@ Hishel is inspired by and builds upon the excellent work in the Python HTTP ecos
|
|
|
416
427
|
* fix: set `after_revalidation=True` for `NeedsToBeUpdated` -> `FromCache` transition by @jlopex in [#402](https://github.com/karpetrosyan/hishel/pull/402)
|
|
417
428
|
|
|
418
429
|
### Contributors
|
|
430
|
+
* @karpetrosyan
|
|
419
431
|
* @martinblech
|
|
420
432
|
* @jlopex
|
|
421
|
-
* @karpetrosyan
|
|
422
433
|
|
|
423
434
|
**Full Changelog**: https://github.com/karpetrosyan/hishel/compare/1.1.2...1.1.3
|
|
424
435
|
|
|
@@ -118,12 +118,24 @@ def _httpx_to_internal(
|
|
|
118
118
|
metadata=headers_metadata,
|
|
119
119
|
)
|
|
120
120
|
elif isinstance(value, httpx.Response):
|
|
121
|
-
if value.is_stream_consumed and "content-encoding" in value.headers:
|
|
122
|
-
raise RuntimeError("Can't get the raw stream of a response with `Content-Encoding` header.")
|
|
123
121
|
stream = (
|
|
124
122
|
make_async_iterator([value.content]) if value.is_stream_consumed else value.aiter_raw(chunk_size=CHUNK_SIZE)
|
|
125
123
|
)
|
|
126
124
|
|
|
125
|
+
if value.is_stream_consumed and "content-encoding" in value.headers:
|
|
126
|
+
# If the stream was consumed and we don't know about
|
|
127
|
+
# the original data and its size, fix the Content-Length
|
|
128
|
+
# header and remove Content-Encoding so we can recreate it later properly.
|
|
129
|
+
headers = Headers(
|
|
130
|
+
{
|
|
131
|
+
**filter_mapping(
|
|
132
|
+
headers,
|
|
133
|
+
["content-encoding"],
|
|
134
|
+
),
|
|
135
|
+
"content-length": str(len(value.content)),
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
|
|
127
139
|
return Response(
|
|
128
140
|
status_code=value.status_code,
|
|
129
141
|
headers=headers,
|
|
@@ -237,6 +237,11 @@ try:
|
|
|
237
237
|
await self._soft_delete_pair(pair, cursor)
|
|
238
238
|
await connection.commit()
|
|
239
239
|
|
|
240
|
+
async def close(self) -> None:
|
|
241
|
+
if self.connection is not None:
|
|
242
|
+
await self.connection.close()
|
|
243
|
+
self.connection = None
|
|
244
|
+
|
|
240
245
|
async def _is_stream_complete(self, pair_id: uuid.UUID, cursor: anysqlite.Cursor) -> bool:
|
|
241
246
|
# Check if there's a completion marker (chunk_number = -1) for response stream
|
|
242
247
|
await cursor.execute(
|
|
@@ -237,6 +237,11 @@ try:
|
|
|
237
237
|
self._soft_delete_pair(pair, cursor)
|
|
238
238
|
connection.commit()
|
|
239
239
|
|
|
240
|
+
def close(self) -> None:
|
|
241
|
+
if self.connection is not None:
|
|
242
|
+
self.connection.close()
|
|
243
|
+
self.connection = None
|
|
244
|
+
|
|
240
245
|
def _is_stream_complete(self, pair_id: uuid.UUID, cursor: sqlite3.Cursor) -> bool:
|
|
241
246
|
# Check if there's a completion marker (chunk_number = -1) for response stream
|
|
242
247
|
cursor.execute(
|
|
@@ -118,12 +118,24 @@ def _httpx_to_internal(
|
|
|
118
118
|
metadata=headers_metadata,
|
|
119
119
|
)
|
|
120
120
|
elif isinstance(value, httpx.Response):
|
|
121
|
-
if value.is_stream_consumed and "content-encoding" in value.headers:
|
|
122
|
-
raise RuntimeError("Can't get the raw stream of a response with `Content-Encoding` header.")
|
|
123
121
|
stream = (
|
|
124
122
|
make_sync_iterator([value.content]) if value.is_stream_consumed else value.iter_raw(chunk_size=CHUNK_SIZE)
|
|
125
123
|
)
|
|
126
124
|
|
|
125
|
+
if value.is_stream_consumed and "content-encoding" in value.headers:
|
|
126
|
+
# If the stream was consumed and we don't know about
|
|
127
|
+
# the original data and its size, fix the Content-Length
|
|
128
|
+
# header and remove Content-Encoding so we can recreate it later properly.
|
|
129
|
+
headers = Headers(
|
|
130
|
+
{
|
|
131
|
+
**filter_mapping(
|
|
132
|
+
headers,
|
|
133
|
+
["content-encoding"],
|
|
134
|
+
),
|
|
135
|
+
"content-length": str(len(value.content)),
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
|
|
127
139
|
return Response(
|
|
128
140
|
status_code=value.status_code,
|
|
129
141
|
headers=headers,
|
|
@@ -10,7 +10,7 @@ from hishel._core._storages._sync_base import SyncBaseStorage
|
|
|
10
10
|
from hishel._core.models import extract_metadata_from_headers
|
|
11
11
|
from hishel._policies import CachePolicy
|
|
12
12
|
from hishel._sync_cache import SyncCacheProxy
|
|
13
|
-
from hishel._utils import snake_to_header
|
|
13
|
+
from hishel._utils import filter_mapping, snake_to_header
|
|
14
14
|
|
|
15
15
|
try:
|
|
16
16
|
import requests
|
|
@@ -94,12 +94,17 @@ def _requests_to_internal(
|
|
|
94
94
|
elif isinstance(model, requests.models.Response):
|
|
95
95
|
try:
|
|
96
96
|
stream = model.raw.stream(amt=CHUNK_SIZE, decode_content=None)
|
|
97
|
+
headers = Headers(filter_mapping(model.headers, ["transfer-encoding"]))
|
|
97
98
|
except requests.exceptions.StreamConsumedError:
|
|
98
99
|
stream = iter([model.content])
|
|
100
|
+
# If the stream was consumed and we don't know about the original
|
|
101
|
+
# data and its size, fix the Content-Length header and remove
|
|
102
|
+
# Content-Encoding so we can recreate it later properly.
|
|
103
|
+
headers = Headers(filter_mapping(model.headers, ["content-encoding", "transfer-encoding"]))
|
|
99
104
|
|
|
100
105
|
return Response(
|
|
101
106
|
status_code=model.status_code,
|
|
102
|
-
headers=
|
|
107
|
+
headers=headers,
|
|
103
108
|
stream=stream,
|
|
104
109
|
)
|
|
105
110
|
else:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|