How to disable HTTP chunking in WSO2 API Manager? (Can be applied to ESB as well)

Method 01:

Using ‘DISABLE_CHUNKING’ property.

<property name="DISABLE_CHUNKING" value="true" scope="axis2" />

When “DISABLE_CHUNKING” set to true, API Manager builds the message to calculate the content length and then sends the particular message to the backend with content length. (e.g. “Content-Length: 25). This can be used if the client sends the request with HTTP chunking or If the message payload received by the client is being modified before sending to the backend. Since the messages gets build per each invocation, having this property will decrease performance.

Method 02

This can be used if the request send by the client contains ‘Content-Length’ header. Here, API Manager/ESB forwards the content length coming from the client request to the backend without building the message and calculating the content length. Since the message doesn’t get build, using below properties will perform better than using ‘DISABLE_CHUNKING’. However, if you change the receiving payload before sending it to the backend, then having this property will result in an error due to a content length mismatch.

<property name="FORCE_HTTP_CONTENT_LENGTH" value="true" scope="axis2"></property>
<property name="COPY_CONTENT_LENGTH_FROM_INCOMING" value="true" scope="axis2"></property>

Method 03

Add "http.headers.preserve=Content-Length" to the <product_home>/repository/conf/" file.

When you add “http.headers.preserve=Content-Length” to the “” file, If the client sends a chunked request (with “Transfer-Encoding: chunked” header) it will get forwarded to the backend. Else if the client sends a request with “Content-Length” header, that header will get forwarded to the backend. Thus, if you are changing the message payload before sending it to the backend the request will fail as the content length you send is not the actual content length of the message.

The main difference between above property and using “FORCE_HTTP_CONTENT_LENGTH” and “COPY_CONTENT_LENGTH_FROM_INCOMING” in an API/proxy service is that “http.headers.preserve=Content-Length” applies at a global level (server level) whereas you can use other 2 properties to have this behaviour local to the API or proxy service.


Like what you read? Give Sewmi Jayaweera a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.