首页 > 解决方案 > 如何使用 SOAPUI 解压缩 GET 响应

问题描述

我收到来自服务器的压缩响应。

和 使用 CURL,| gunzip我能够获得解压缩的内容响应,但我不想使用 CURL 并直接通过 SOAPUI、标题或脚本解压缩它。

我试着写一些类似的东西:

def responseBody=testRunner.testCase.getTestStepByName("getZIp").httpRequest.response.responseContent;
InputStream ins = new ByteArrayInputStream(responseBody.getBytes())

    log.info responseBody
    def outFile = new FileOutputStream(new File('/users/trythis.zip'))
    if (ins) {
    com.eviware.soapui.support.Tools.writeAll(outFile, ins )
    }
    ins.close()
    outFile.close()

但数据仍然被压缩。

标签: groovygethttp-headerscompressionsoapui

解决方案


直截了当的东西,例如:

InputStream ins = new ByteArrayInputStream(responseBody.getBytes())
def outFile = new File('/users/trythis.txt')
new GZIPInputStream( ins ).withReader{ outFile << it }

推荐阅读