Skip to content

content-length header dropped on HTTP/3 requests #6830

Description

@alukach

What versions & operating system are you using?

  System:
    OS: macOS 26.5
    CPU: (11) arm64 Apple M3 Pro
    Memory: 115.63 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.19.1 - /Users/alukach/.nvm/versions/node/v20.19.1/bin/node
    npm: 10.8.2 - /Users/alukach/.nvm/versions/node/v20.19.1/bin/npm
    pnpm: 8.15.5 - /Users/alukach/.nvm/versions/node/v20.19.1/bin/pnpm
  npmPackages:
    @cloudflare/workers-types: ^4.20250601.0 => 4.20260606.1
    wrangler: ^4.20.0 => 4.86.0

Please provide a link to a minimal reproduction

https://github.com/alukach/cf-workers-head-content-length-bug

Describe the Bug

When a HEAD request is sent over HTTP/3, the response comes back missing a content-length header. The header is present for the same request/server over HTTP/2 or HTTP1.

The worker logic is very simple:

const BODY = "Hello from a Cloudflare Worker.\n";
const CONTENT_LENGTH = String(new TextEncoder().encode(BODY).byteLength);

export default {
  async fetch(request: Request): Promise<Response> {
    const headers = {
      "content-type": "text/plain; charset=utf-8",
      "content-length": CONTENT_LENGTH,
    };

    // HEAD carries no body but still advertises the size.
    if (request.method === "HEAD") {
      return new Response(null, { headers });
    }

    return new Response(BODY, { headers });
  },
};

(copy/paste from https://community.cloudflare.com/t/content-length-header-missing-on-http-3-head-requests/932208)

Please provide any relevant error logs

# content-length present on HTTP/2 requests
▶ docker run --rm --platform linux/amd64 ymuski/curl-http3 \
    curl --http2 -sI https://cf-missing-content-length.alukach.workers.dev
HTTP/2 200
date: Sat, 06 Jun 2026 20:38:48 GMT
content-type: application/octet-stream
content-length: 4873129725
cf-ray: a07a390a8a245c9d-YVR
cf-cache-status: DYNAMIC
accept-ranges: bytes
etag: "96aef95a001f80149b0d5a8eb7e77932-581"
last-modified: Wed, 04 Dec 2024 22:00:18 GMT
server: cloudflare
x-amz-id-2: lXOphchlNx386l8+V1wOCipadOjDWQ1/0xQbqwf1yidbsJmknXVL7G1qpOA4eTwFayuGRdXxcL0=
x-amz-request-id: PDP4HFSRYF3RP219
x-amz-server-side-encryption: AES256
x-amz-version-id: Kh_uXM_g91CtDHmqwiWhvZfKhiCQQu6u
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=1I3CWAL%2Fyi8U70%2Fyhn%2BvSpNvqhkuSSEbDKK8bzUR3lasA2%2FFBHaCL6mh77Jnj6vol0sUaYRlb1m0yS%2FtRei8Sog7fm73ZB6uQLsA0lSB%2FAKoiaWOYAhl4XoGLWXlPLUqRF1iQlAodOGtpFVXTd67HKMa9d6V1s1KnZAbPQ%3D%3D"}]}
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
alt-svc: h3=":443"; ma=86400

# content-length missing on HTTP/3 requests
▶ docker run --rm --platform linux/amd64 ymuski/curl-http3 \
    curl --http3 -sI https://cf-missing-content-length.alukach.workers.dev
HTTP/3 200
nel: {"report_to":"cf-nel","success_fraction":0.0,"max_age":604800}
report-to: {"group":"cf-nel","max_age":604800,"endpoints":[{"url":"https://a.nel.cloudflare.com/report/v4?s=ba0e3PqQNnKl5ajNVFNcPHUzqp8aAA2XItRCTS9KFiBrdTYPnuPrYpWjijsDTjPvKWufM4Gz8Koje%2Birkkzm9ypKxnsP9G5YfhAVcaPWimUoJj4jkKxbd1jgB8hq1Ue4%2FW0ul5WWKU9%2B5BQuWYhU9ku1Zhzprb22Vrtjog%3D%3D"}]}
date: Sat, 06 Jun 2026 20:38:56 GMT
content-type: application/octet-stream
priority: u=3,i=?0
cf-ray: a07a39382bf25c9d-YVR
cf-cache-status: DYNAMIC
accept-ranges: bytes
etag: "96aef95a001f80149b0d5a8eb7e77932-581"
last-modified: Wed, 04 Dec 2024 22:00:18 GMT
server: cloudflare
x-amz-id-2: rWw37E7d3fWg4sa8x7iYu6wzEO/WNnHf3CpYtXk9aKcPf+4tyP13wturActexQrczrIrxTQaMhw=
x-amz-request-id: 6ZM87ZC2SXT58AMJ
x-amz-server-side-encryption: AES256
x-amz-version-id: Kh_uXM_g91CtDHmqwiWhvZfKhiCQQu6u
alt-svc: h3=":443"; ma=86400
server-timing: cfExtPri

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    Status
    Other

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions