diff --git a/asgineer/utils.py b/asgineer/utils.py
index fffe0fd..893d0e7 100644
--- a/asgineer/utils.py
+++ b/asgineer/utils.py
@@ -140,6 +140,11 @@ def make_asset_handler(assets, max_age=0, min_compress_size=256):
         else:
             body = assets[path]
 
+        # The response to a head request should not include a body
+        if request.method == "HEAD":
+            headers["content-length"] = str(len(body))
+            body = b""
+
         # Note that we always return bytes, not a stream-response. The
         # assets used with this utility are assumed to be small-ish,
         # since they are in-memory.

Asset handler should not return a body for HEAD requests.
diff --git a/tests/test_utils.py b/tests/test_utils.py
index 1409149..042fac3 100644
--- a/tests/test_utils.py
+++ b/tests/test_utils.py
@@ -54,7 +54,8 @@ def test_make_asset_handler():
     r2b = server.get("foo.png")
 
     assert r1a.status == 200 and r1b.status == 200
-    assert len(r1a.body) == 3 and len(r1a.body) == 3
+    assert len(r1a.body) == 3
+    assert len(r1b.body) == 0  # HEAD's have no body
 
     for r in (r1a, r1b):
         assert r.headers["content-type"] == "text/html"

pip install -e .[dev]
parse_log_pytest
pytest
pytest pytest-cov requests websockets
apt-get update apt-get install -y gcc
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
-e git+https://github.com/almarklein/asgineer.git@dbd7fd111c5aa3a7f3ad1374441e0062bd4cd5f4#egg=asgineer
certifi==2025.1.31
charset-normalizer==3.4.1
coverage==7.8.0
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
idna==3.10
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
pytest @ file:///croot/pytest_1738938843180/work
pytest-cov==6.0.0
requests==2.32.3
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
urllib3==2.3.0
websockets==15.0.1

name: asgineer
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - certifi==2025.1.31
      - charset-normalizer==3.4.1
      - coverage==7.8.0
      - idna==3.10
      - pytest-cov==6.0.0
      - requests==2.32.3
      - urllib3==2.3.0
      - websockets==15.0.1
prefix: /opt/conda/envs/asgineer

tests/test_utils.py::test_make_asset_handler
tests/test_utils.py::test_make_asset_handler_fails tests/test_utils.py::test_make_asset_handler_max_age
asgineer/utils.py
asgineer/utils.py