Gateway returns Content-Type header on 204 No Content response
search cancel

Gateway returns Content-Type header on 204 No Content response

book

Article ID: 454221

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

When a backend service responds with an HTTP 204 No Content status, the Layer7 API Gateway (version 11.1) incorrectly includes a Content-Type: application/json header in the response to the client.

This behavior may cause errors for clients that strictly follow RFC guidelines and do not expect a Content-Type header when there is no response body.

Environment

  • Product: Layer7 API Gateway
  • Version: 11.1

Cause

The issue is related to how the underlying Tomcat engine and Gateway core flow handle the 204 status. While Tomcat generally strips Content-Type for 204 responses, it does not automatically do so for 204 responses if a value is provided by the policy or backend. This behavior was changed in later versions to be more restrictive by default.

Resolution

This issue is officially resolved in API Gateway version 11.2.2.

A new Cluster-Wide Property (CWP) has been introduced to allow administrators to explicitly strip these headers from 204 responses.

Implementation Steps

  1. Upgrade: Ensure the Gateway is running version 11.2.2 or later.
  2. Enable Property: Log in to the Policy Manager and navigate to Tasks > Global Settings > Manage Cluster-Wide Properties.
  3. Add/Edit Property: Add or update the following property:
    • Name: io.httpStripContentTypeOn204
    • Value: true
    • Default: false (The property is disabled by default to maintain backward compatibility).

Once set to true, the Gateway will automatically omit both Content-Type and Content-Length headers from all 204 No Content responses, regardless of the backend service configuration or routing policy.