0

我想记录使用org.apache.http.client制作的帖子的正文。我正在使用Scalatra版本2.4.0.RC3和Scala版本2.11.7。我的回复是一个400错误的请求,我需要获取响应正文中提供的消息。斯卡拉ByteArrayInputStream字符串

这里是我当前的代码:

val response = client.execute(post) 
println(response) 
println(response.getEntity().getContent()) 

response.getEntity()的getContent()打印:

[email protected] 

我需要得到实际的身体从这个ByteArrayInputStream的字符串。

回答

1

您可以使用EntityUtils形成相同的库:

import org.apache.http.util.EntityUtils; 
println(EntityUtils.toString(response.getEntity()));