wso2 / product-apim

Welcome to the WSO2 API Manager source code! For info on working with the WSO2 API Manager repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
841 stars 785 forks source link

When trying to retrieve a jpg image by enabling Response Caching, not returning the image as the response #5948

Closed riyazathali closed 7 months ago

riyazathali commented 5 years ago

Description: When trying to retrieve a jpg image (as the backend) with API Manager 2.2.0 and it can successfully retrieve with the below builders and formatters in axis.xml

<messageBuilder contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamBuilder"/>
<messageFormatter contentType="application/json"
class="org.apache.synapse.commons.json.JsonStreamFormatter"/>

But when enabling response caching in the API publisher portal, there is an issue with message building which cause to throw 'java.io.CharConversionException: Invalid UTF-8 start byte 0xff' error. This can be omitted by adding following messageBuilder and messageFormatter to axis2.xml.

<messageBuilder contentType="image/jpeg" class="org.wso2.carbon.relay.BinaryRelayBuilder"/>
<messageFormatter contentType="image/jpeg" class="org.wso2.carbon.relay.ExpandingMessageFormatter"/>

After adding the above, when trying to test by enabling response caching and noticed that the first request only was succeeded and 2nd request wasn't succeeded and not returning the image as the response. This second request not returning the intended 'Content-Type: image/jpg' and return 'application/soap+xml' as the Content-Type in debug logs..

Affected Product Version: APIM 2.2.0

saravanpa-aot commented 3 years ago

Is there any resolution for this ? has this been addressed in any newer versions?