<sequence xmlns="http://ws.apache.org/ns/synapse" name="_cors_request_handler_">
   <filter source="$ctx:CORSConfiguration.Enabled" regex="true">
      <then>
         <filter source="boolean($trp:Access-Control-Allow-Origin)" regex="false">
            <then>
               <property name="Access-Control-Allow-Origin" expression="$ctx:Access-Control-Allow-Origin"  scope="transport" type="STRING"/>
            </then>
         </filter>
         <filter source="boolean($trp:Access-Control-Allow-Methods)" regex="false">
            <then>
               <property name="Access-Control-Allow-Methods" expression="$ctx:Access-Control-Allow-Methods" scope="transport" type="STRING"/>
            </then>
         </filter>
         <filter source="boolean($trp:Access-Control-Allow-Headers)" regex="false">
            <then>
               <property name="Access-Control-Allow-Headers" expression="$ctx:Access-Control-Allow-Headers" scope="transport" type="STRING"/>
            </then>
         </filter>
         <filter source="boolean($trp:Access-Control-Allow-Credentials)" regex="false">
            <then>
               <filter source="boolean($ctx:Access-Control-Allow-Credentials)" regex="true">
                  <then>
                     <property name="Access-Control-Allow-Credentials" expression="$ctx:Access-Control-Allow-Credentials" scope="transport" type="STRING"/>
                  </then>
               </filter>
            </then>
         </filter>
         <filter source="boolean($trp:Access-Control-Expose-Headers)" regex="false">
            <then>
               <property name="Access-Control-Expose-Headers" expression="$ctx:Access-Control-Expose-Headers" scope="transport" type="STRING"/>
            </then>
         </filter>
      </then>
   </filter>
</sequence>
