Skip to content

Add validation for conflicting Content-Length values between Body and Headers #164

Closed

Description

@coderabbitai

Problem

Currently, Content-Length can be set both on the Body object and in Headers, which can lead to potential conflicts and confusion:

  • If set on Body, it wins over any value in Headers (since Body value is set last)
  • This dual assignment capability creates an "oddness" where developers might accidentally set conflicting values
  • No validation currently exists to detect or prevent such conflicts

Proposed Solution

Return a 500 Internal Server Error when Content-Length is set on both Body and Headers with conflicting values.

Context

This issue emerged from the discussion in PR #161 about Content-Length header handling:

Related

Reported by: @nielsenko

Activity

  1. added
    area: headers
    enhancement
    on Sep 11, 2025
  2. SandPod commented on Sep 11, 2025

    @SandPod
    Contributor

    Suggestion for updated proposal: Attempt to set it from the body if and only if the header is not set. If header is set, use that.

  3. added this to the 1.0 Release milestone on Sep 11, 2025
  4. moved this from Inbox 📫 to Backlog 🗂️ in Serverpod Frameworkson Sep 11, 2025
  5. moved this from Backlog 🗂️ to Done 🚀 in Serverpod Frameworkson Nov 27, 2025
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

    area: headersenhancement

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions