mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Add ETag header for static responses (#2306)
* add etag to static responses * fix RuntimeError related to static headers * Remove unnecessary import --------- Co-authored-by: Simon Willison <swillison@gmail.com>
This commit is contained in:
parent
261fc8d875
commit
67e66f36c1
4 changed files with 55 additions and 2 deletions
|
|
@ -706,3 +706,15 @@ def test_truncate_url(url, length, expected):
|
|||
def test_pairs_to_nested_config(pairs, expected):
|
||||
actual = utils.pairs_to_nested_config(pairs)
|
||||
assert actual == expected
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_calculate_etag(tmp_path):
|
||||
path = tmp_path / "test.txt"
|
||||
path.write_text("hello")
|
||||
etag = '"5d41402abc4b2a76b9719d911017c592"'
|
||||
assert etag == await utils.calculate_etag(path)
|
||||
assert utils._etag_cache[path] == etag
|
||||
utils._etag_cache[path] = "hash"
|
||||
assert "hash" == await utils.calculate_etag(path)
|
||||
utils._etag_cache.clear()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue