當前位置: 首頁>>代碼示例>>Java>>正文


Java ClientHttpResponse.getBody方法代碼示例

本文整理匯總了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=================================================");
}
 
開發者ID:kloiasoft,項目名稱:eventapis,代碼行數:17,代碼來源:RequestInterceptor.java

示例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;
}
 
開發者ID:voyages-sncf-technologies,項目名稱:cerebro,代碼行數:13,代碼來源:SeyrenResponseErrorHandler.java

示例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];
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:13,代碼來源:DefaultResponseErrorHandler.java

示例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];
}
 
開發者ID:FastBootWeixin,項目名稱:FastBootWeixin,代碼行數:12,代碼來源:WxResponseErrorHandler.java


注:本文中的org.springframework.http.client.ClientHttpResponse.getBody方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。