Skip to content

Link relay: a prepared body shorter than its declared Content-Length is forwarded as complete #8604

Closed

Description

@lidge-jun

From the fresh final review of #8594 at 47b9890 (approved with this one nit).

readDeclaredBody in src/client/link-request-compression.ts returns the shorter slice when a compressible request body ends cleanly before its declared Content-Length, and the relay (src/client/link-relay.ts, the prepared-body path) then rewrites Content-Length to that shorter length. The Home receives a body that looks complete, although the client declared more. The streamed path keeps the declared length, so there the Home sees a short upload.

In practice the truncated JSON almost always fails to parse and the request ends in a 400. Whether Bun ever ends a request body cleanly when it is short was not checked, so this may be unreachable.

Smallest fix: in readDeclaredBody, treat filled !== declared as unreadable and throw; the relay already maps that to a 400. Add a test with a body shorter than its declared length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions