search cancel

Manually gzip response using Encode/Decode Assertion

book

Article ID: 239057

calendar_today

Updated On:

Products

CA API Gateway

Issue/Introduction

Hi Team, 

  We disabled the  response.compress.gzip.allow to false and want to encode the response using Encode/Decode Asserttion. but not working as desired.

Could you please provide an example on how to configure the Encode/Decode Assertion for gzip compressing

 

Environment

Release : 9.4

Component : API GATEWAY

Resolution

Both gzip tactical assertion and encode/decode data assertion are working, the trick is, when compress, need to compress the payload as message, and give correct content-type of the payload

<?xml version="1.0" encoding="UTF-8"?>
<exp:Export Version="3.0"
    xmlns:L7p="http://www.layer7tech.com/ws/policy"
    xmlns:exp="http://www.layer7tech.com/ws/policy/export" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">
    <exp:References>
        <CustomAssertionReference RefType="com.l7tech.console.policy.exporter.CustomAssertionReference">
            <CustomAssertionName>GZip / GUnzip Data</CustomAssertionName>
        </CustomAssertionReference>
    </exp:References>
    <wsp:Policy xmlns:L7p="http://www.layer7tech.com/ws/policy" xmlns:wsp="http://schemas.xmlsoap.org/ws/2002/12/policy">
        <wsp:All wsp:Usage="Required">
            <L7p:SetVariable>
                <L7p:Base64Expression stringValue="dGhpcyBpcyBhIHJlc3AgZ3ppcCB0ZXN0"/>
                <L7p:VariableToSet stringValue="myresp"/>
            </L7p:SetVariable>
            <L7p:CustomAssertion>
                <L7p:base64SerializedValue>rO0ABXNyADFjb20ubDd0ZWNoLnBvbGljeS5hc3NlcnRpb24uQ3VzdG9tQXNzZXJ0aW9uSG9sZGVyZtcreFwddTICAAlaAAxpc1VpQXV0b09wZW5MAApjYXRlZ29yaWVzdAAPTGphdmEvdXRpbC9TZXQ7TAAIY2F0ZWdvcnl0ACpMY29tL2w3dGVjaC9wb2xpY3kvYXNzZXJ0aW9uL2V4dC9DYXRlZ29yeTtMAA9jdXN0b21Bc3NlcnRpb250ADFMY29tL2w3dGVjaC9wb2xpY3kvYXNzZXJ0aW9uL2V4dC9DdXN0b21Bc3NlcnRpb247TAAUY3Vzd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vcm1hdAAAAAAAAAAAEgAAeHIADmphdmEubGFuZy5FbnVtAAAAAAAAAAASAAB4cHQAA1pJUHQAGXRleHQvcGxhaW47IGNoYXJzZXQ9dXRmLTh0AAZteXJlc3BzcgAjY29tLmw3dGVjaC5wb2xpY3kudmFyaWFibGUuRGF0YVR5cGVvzp9dwTT0zAIAA0wABG5hbWVxAH4ABEwACXNob3J0TmFtZXEAfgAEWwAMdmFsdWVDbGFzc2VzdAASW0xqYXZhL2xhbmcvQ2xhc3M7eHB0AAdNZXNzYWdldAAHbWVzc2FnZXVyABJbTGphdmEubGFuZy5DbGFzczurFteuy81amQIAAHhwAAAAAXZyABBqYXZhLmxhbmcuT2JqZWN0AAAAAAAAAAAAAAB4cHQABm15cmVzcHQANGJhYTgxZTJhY2JlODQwOWZlODJhNjMzY2IyNWI3NTQ3NGFmMjU1MDE4ZjEyNGQyYi5qYXJ0ABNHWmlwIG9yIEdVbnppcCBkYXRhdAASR1ppcCAvIEdVbnppcCBEYXRhdAASR1ppcCAvIEdVbnppcCBEYXRhcA==</L7p:base64SerializedValue>
            </L7p:CustomAssertion>
            <L7p:EncodeDecode>
                <L7p:SourceVariableName stringValue="myresp"/>
                <L7p:TargetContentType stringValue="text/plain; charset=utf-8"/>
                <L7p:TargetDataType variableDataType="message"/>
                <L7p:TargetVariableName stringValue="myresp"/>
                <L7p:TransformType transformType="GZIP"/>
            </L7p:EncodeDecode>
            <L7p:HardcodedResponse>
                <L7p:Base64ResponseBody stringValue="JHtteXJlc3B9"/>
                <L7p:ResponseContentType stringValue="text/plain; charset=UTF-8"/>
            </L7p:HardcodedResponse>
            <L7p:AddHeader>
                <L7p:HeaderName stringValue="Content-Encoding"/>
                <L7p:HeaderValue stringValue="gzip"/>
                <L7p:RemoveExisting booleanValue="true"/>
                <L7p:Target target="RESPONSE"/>
            </L7p:AddHeader>
        </wsp:All>
    </wsp:Policy>
</exp:Export>

Attachments