Mulesoft - 如何将内容编码设置为 gzip 以便在 http API 调用中压缩我的有效负载

Mulesoft - How to set Content-Encoding as gzip in order to compress my payload in http API call

我正在使用 Mule 3.8。如何设置 Content-Encoding: gzip 以压缩我的负载,External_API 接受 gzip 压缩负载作为输入??

我正在使用 until-successful 来重试我的 http API 调用。我没有得到正确的文档如何在 http 请求中设置 gzip 以便压缩有效负载。

    <flow name="Ingestion_with_retries_Flow" >
    <until-successful objectStore-ref="objectStore" maxRetries="${max.retries}" deadLetterQueue-ref="Queue_Failed_Payload_To_ErrorDir_And_Notify"
                      failureExpression="#[(exception != null) and (exception.causedBy(java.net.ConnectException) || exception.causedBy(java.net.SocketTimeoutException) || exception.causedBy(java.net.SocketException) || exception.causedBy(java.io.IOException))]"
                      doc:name="Until Successful" millisBetweenRetries="${millis.between.retries}">
        <processor-chain doc:name="Processor Chain">
            <http:request config-ref="HTTPS_Ingestion_Service_External_API" path="/delivery" method="POST" doc:name="External API Data Delivery Post">
                <http:request-builder>
                    <http:header headerName="Accept" value="${http.by.interface.version}"/>

                </http:request-builder>
                <http:success-status-code-validator values="200"/>
            </http:request>

            <json:xml-to-json-transformer doc:name="XML to JSON"/>
            <flow-ref name="Subflow_Extract_Ingestion_Response" doc:name="Extract Ingestion Response"/>
        </processor-chain>
    </until-successful>
</flow>

只需使用压缩模块的 Compress 元素来压缩输入负载。

然后您可以将输入侦听器的响应 header 设置为 Content-Encoding=gzip。这让 caller/browser 知道响应负载是 gzip 编码的。