Friday, July 25, 2014

WSO2 API Manager proxing without chunking

I recently was working with a client who had a backend server which could not accept chunked content. For example, this may occur with an early version Windows .NET framework backend.  If you have any backend server that can't chew a chunked http body, perhaps this post will help you.

The Symptoms: 

The backend server is not able to return a response to post or put HTTP calls.  If you disable chunking globally, the backend server may be unable to parse get requests.


The Solution:

Disable chunking, but only for post and put requests.  This can be done through customizing the velocity template by adding some custom logic.  The velocity_template.xml file is located in <InstallDir>/repository/resources/api_templates/ . Changing this file will affect future APIs created in API manager.

Changes to the Velocity template:

The sections of the API template that handle responses can filter them by HTTP method.  I've added a simple choice based on HTTP method, and added a new block for Posts and Puts that has this property:
   <property name="DISABLE_CHUNKING" value="true" scope="axis2"/>

The exact code was a bit big for a blog, so I put it in a Google Doc.  Please note that this will be out-dated pretty quickly.  It is written for WSO2 APIM 1.7.0.

https://drive.google.com/file/d/0B0dBKhEyYLmVQXlUbm84QWFNNzQ/edit?usp=sharing


Cheers, Y'all!

No comments:

Post a Comment