我从服务器收到压缩响应。
使用 CURL 和 | gunzip
我能够获得解压缩的内容响应,但我不想使用 CURL 并直接通过 SOAPUI、 header 或脚本对其进行解压缩。
我试着写一些类似的东西:
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()
但数据仍然被压缩。
最佳答案
直接的东西,例如:
InputStream ins = new ByteArrayInputStream(responseBody.getBytes())
def outFile = new File('/users/trythis.txt')
new GZIPInputStream( ins ).withReader{ outFile << it }
关于groovy - 如何使用 SOAPUI 解压缩 GET 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56465977/