本文整理匯總了Java中org.springframework.http.client.ClientHttpResponse.getBody方法的典型用法代碼示例。如果您正苦於以下問題:Java ClientHttpResponse.getBody方法的具體用法?Java ClientHttpResponse.getBody怎麽用?Java ClientHttpResponse.getBody使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.http.client.ClientHttpResponse
的用法示例。
在下文中一共展示了ClientHttpResponse.getBody方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: traceResponse
import org.springframework.http.client.ClientHttpResponse; //導入方法依賴的package包/類
private void traceResponse(ClientHttpResponse response) throws IOException {
StringBuilder inputStringBuilder = new StringBuilder();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(response.getBody(), "UTF-8"));
String line = bufferedReader.readLine();
while (line != null) {
inputStringBuilder.append(line);
inputStringBuilder.append('\n');
line = bufferedReader.readLine();
}
log.debug("============================response begin==========================================");
log.debug("Status code : {}", response.getStatusCode());
log.debug("Status text : {}", response.getStatusText());
log.debug("Headers : {}", response.getHeaders());
log.debug("Response body: {}", inputStringBuilder.toString());
log.debug("=======================response end=================================================");
}
示例2: handleError
import org.springframework.http.client.ClientHttpResponse; //導入方法依賴的package包/類
@Override
public void handleError(ClientHttpResponse response) throws IOException {
String seyrenResponseBody;
LOGGER.debug("Response : {} {}", response.getStatusCode(), response.getStatusText());
if (response.getBody() != null) {
seyrenResponseBody = CharStreams.toString(new InputStreamReader(response.getBody(), "UTF-8"));
} else {
seyrenResponseBody = "Response whithout body";
}
CerebroException exception = new CerebroException(ErrorCode.SEYREN_ERROR, seyrenResponseBody);
throw exception;
}
示例3: getResponseBody
import org.springframework.http.client.ClientHttpResponse; //導入方法依賴的package包/類
private byte[] getResponseBody(ClientHttpResponse response) {
try {
InputStream responseBody = response.getBody();
if (responseBody != null) {
return FileCopyUtils.copyToByteArray(responseBody);
}
}
catch (IOException ex) {
// ignore
}
return new byte[0];
}
示例4: getResponseBody
import org.springframework.http.client.ClientHttpResponse; //導入方法依賴的package包/類
protected byte[] getResponseBody(ClientHttpResponse response) {
try {
InputStream responseBody = response.getBody();
if (responseBody != null) {
return FileCopyUtils.copyToByteArray(responseBody);
}
} catch (IOException ex) {
// ignore
}
return new byte[0];
}