https://bz.apache.org/bugzilla/show_bug.cgi?id=69803

            Bug ID: 69803
           Summary: HTTP/1.1 Connector Content-Length header calculation
                    regression causing Chrome/Edge
                    net::ERR_CONTENT_LENGTH_MISMATCH
           Product: Tomcat 9
           Version: 9.0.107
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: blocker
          Priority: P2
         Component: Catalina
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: -----

Created attachment 40092
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=40092&action=edit
Failed to load resource: net::ERR_CONTENT_LENGTH_MISMATCH -> from chrome -
Tomcat 9.0.107 / 9.0.108

# Apache Tomcat Bug Report - ERR_CONTENT_LENGTH_MISMATCH in 9.0.107+

## Bug Summary
**Title:** HTTP/1.1 Connector Content-Length header calculation regression
causing Chrome/Edge ERR_CONTENT_LENGTH_MISMATCH

**Severity:** Blocker - Prevents upgrade to newer Tomcat versions
**Component:** Catalina (HTTP Connector)
**Affects Versions:** 9.0.107, 9.0.108
**Working Version:** 9.0.106

## Description
The HTTP/1.1 connector in Tomcat 9.0.107 and 9.0.108 has a regression where the
Content-Length header value doesn't match the actual response body size,
causing Chrome and Edge browsers to fail with
`net::ERR_CONTENT_LENGTH_MISMATCH` error. Firefox browsers work fine with the
same responses. This is a blocking issue preventing upgrades from 9.0.106 to
newer versions.

## Steps to Reproduce
1. Deploy any web application with docker base image as Tomcat 9.0.107 or
9.0.108
2. Access the application using Chrome browser
3. Observe network requests in Chrome DevTools
4. Requests fail with `net::ERR_CONTENT_LENGTH_MISMATCH`

## Expected Behavior
- Content-Length header should match actual response body size
- All browsers should receive complete responses without errors

## Actual Behavior
- Server sends `Content-Length: 5243` but delivers only `5206` bytes (37 bytes
missing)
- Chrome and Edge browsers fail with `net::ERR_CONTENT_LENGTH_MISMATCH`
- Firefox accepts the response and works normally

## Environment
- **Tomcat Version:** 9.0.107, 9.0.108 (regression from 9.0.106)
- **Browsers Affected:** Chrome 139.x, Microsoft Edge (Chromium-based)
- **Browser Working:** Firefox 142.x

## Evidence
### Chrome HAR Analysis
```json
{
  "response": {
    "status": 200,
    "headers": [{"name": "content-length", "value": "5243"}],
    "content": {"size": 5206, "bodySize": 5206},
    "_error": "net::ERR_CONTENT_LENGTH_MISMATCH"
  }
}
```

### Firefox HAR Analysis
```json
{
  "response": {
    "status": 200,
    "headers": [{"name": "content-length", "value": "5243"}],
    "content": {"bodySize": 5206},
    "_error": null
  }
}
```

## Root Cause Analysis
The issue appears to be in the HTTP/1.1 connector where Content-Length
calculation occurs before final response buffering/encoding, leading to a
discrepancy between the declared header value and actual transmitted bytes.

## Regression Confirmation
- **9.0.106:** Works correctly in all browsers
- **9.0.107:** Content-Length mismatch, Chrome/Edge fail
- **9.0.108:** Same issue persists

## Impact
- **Blocker:** Cannot upgrade from 9.0.106 to newer Tomcat versions
- High impact for Chrome/Edge users (majority browser market share)
- Breaks web applications during routine Tomcat upgrades
- Forces production systems to remain on older versions

## Additional Information
This regression prevents upgrading from 9.0.106 to newer versions. The 37-byte
discrepancy is consistent across different requests, suggesting a systematic
calculation error in the connector implementation introduced between 9.0.106
and 9.0.107.

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to