org.apache.http.ConnectionClosedException:块编码消息体的提前结束:关闭块预期

问题描述 投票:4回答:1

我正在尝试RestAssured并撰写以下声明 -

String URL = "http://XXXXXXXX";
Response result = given().
            header("Authorization","Basic xxxx").
            contentType("application/json").
            when().
            get(url);
JsonPath jp = new JsonPath(result.asString());

在最后一个声明中,我收到以下异常:

org.apache.http.ConnectionClosedException: Premature end of chunk coded message body: closing chunk expected

我的回复中返回的标头是:

Content-Type → application/json; qs=1 Date → Tue, 10 Nov 2015 02:58:47 GMT Transfer-Encoding → chunked

任何人都可以指导我解决这个异常并指出我是否遗漏了任何内容或任何不正确的实现。

apache http rest-assured chunked-encoding rest-assured-jsonpath
1个回答
0
投票

也许你可以尝试摆弄connection config?例如:

given().config(RestAssured.config().connectionConfig(connectionConfig().closeIdleConnectionsAfterEachResponse())). ..
© www.soinside.com 2019 - 2024. All rights reserved.