wso2 - Is there a way to turn on global payload compression (gzip) on the ESB or API Manager? -
is there way switch on payload compression on either esb (< 5.0.0) or api manager (< 2.0.0) , application/json content-type ?
i have achieved on resource level global option ideal.
after research have found following available option in catalina-server.xml :
compression="on" & compressablemimetype.
this not tomcat servers web interface , not services , axis2 for.
after more digging found archived article http://wso2.com/library/3316/. inside references following :
"mc_gzip_response (server, writable) : default http response body not compressed. set message context property true have response body gzip compressed."
sounds need , not sure set parameter.
thanks "ycr". set me on right path.
what did achieve create global custom insequence , outsequence (global extensions) api's deployed inside api manager , mentioned in https://docs.wso2.com/display/am1100/adding+mediation+extensions.
the insequence checks value/existence of accept-encoding header of request , outsequence gzips response accordingly.
steps:
create "insequence" handler xml file:
<sequence xmlns="http://ws.apache.org/ns/synapse" name="wso2am--ext--in"> <property name="encoding" expression="$trp:accept-encoding"/> <filter xpath="fn:contains(fn:lower-case(get-property('encoding')) , 'gzip')"> <then> <property name="compression" value="true"/> </then> <else> <property name="compression" value="false"/> </else> </filter>
the file name can name inside tag needs wso2am--ext--in
similarly create "outsequence" file :
<sequence xmlns="http://ws.apache.org/ns/synapse" name="wso2am--ext--out"> <filter source="get-property('compression')" regex="true"> <then> <property action="remove" name="transport_headers" scope="axis2"/> <property name="content-encoding" scope="transport" type="string" value="gzip"/> <property name="transfer-encoding" scope="transport" type="string" value="gzip"/> </then> <else> <property name="transport_headers" action="remove" scope="axis2"/> </else> </filter>
copy files inside /repository/deployment/server/synapse-configs/default/sequences directory. hot-deployed.
send request deployed api header accept-encoding set gzip (any string gzip in compressed) , should respond content-encoding: gzip
Comments
Post a Comment