本文整理了Java中co.cask.common.http.HttpResponse.getResponseMessage()
方法的一些代码示例,展示了HttpResponse.getResponseMessage()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.getResponseMessage()
方法的具体详情如下:
包路径:co.cask.common.http.HttpResponse
类名称:HttpResponse
方法名:getResponseMessage
暂无
代码示例来源:origin: co.cask.cdap/cdap-authentication-client
/**
* Executes fetch access token request.
*
* @param request the http request to fetch access token from the authentication server
* @return {@link AccessToken} object containing the access token
* @throws IOException IOException in case of a problem or the connection was aborted or if the access token is not
* received successfully from the authentication server
*/
private AccessToken execute(HttpRequest request) throws IOException {
HttpResponse response = HttpRequests.execute(request, getHttpRequestConfig());
LOG.debug("Got response {} - {} from {}", response.getResponseCode(), response.getResponseMessage(), pingURI);
if (response.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new HttpFailureException(response.getResponseMessage(), response.getResponseCode());
}
Map<String, String> responseMap =
ObjectResponse.fromJsonBody(response, ACCESS_TOKEN_RESPONSE_TYPE_TOKEN).getResponseObject();
String tokenValue = responseMap.get(ACCESS_TOKEN_KEY);
String tokenType = responseMap.get(TOKEN_TYPE_KEY);
String expiresInStr = responseMap.get(EXPIRES_IN_KEY);
LOG.debug("Response map from auth server: {}", responseMap);
if (StringUtils.isEmpty(tokenValue) || StringUtils.isEmpty(tokenType) || StringUtils.isEmpty(expiresInStr)) {
throw new IOException("Unexpected response was received from the authentication server.");
}
return new AccessToken(tokenValue, Long.valueOf(expiresInStr), tokenType);
}
代码示例来源:origin: co.cask.cdap/cdap-authentication-client
/**
* Fetches the available authentication server URL, if authentication is enabled in the gateway server,
* otherwise, empty string will be returned.
*
* @return string value of the authentication server URL
* @throws IOException IOException in case of a problem or the connection was aborted or if url list is empty
*/
private String fetchAuthURI() throws IOException {
if (pingURI == null) {
throw new IllegalStateException("Connection information not set!");
}
LOG.debug("Try to get the authentication URI from the gateway server: {}.", pingURI);
HttpResponse response = HttpRequests.execute(HttpRequest.get(pingURI.toURL()).build(), getHttpRequestConfig());
LOG.debug("Got response {} - {} from {}", response.getResponseCode(), response.getResponseMessage(), pingURI);
if (response.getResponseCode() != HttpURLConnection.HTTP_UNAUTHORIZED) {
return "";
}
Map<String, List<String>> responseMap =
ObjectResponse.fromJsonBody(response, AUTH_URL_RESPONSE_TYPE_TOKEN).getResponseObject();
LOG.debug("Response map from gateway server: {}", responseMap);
String result;
List<String> uriList = responseMap.get(AUTH_URI_KEY);
if (uriList != null && !uriList.isEmpty()) {
result = uriList.get(RANDOM.nextInt(uriList.size()));
} else {
throw new IOException("Authentication servers list is empty.");
}
return result;
}
代码示例来源:origin: caskdata/cdap
output.printf("< %s %s\n", response.getResponseCode(), response.getResponseMessage());
for (Map.Entry<String, String> header : response.getHeaders().entries()) {
output.printf("< %s: %s\n", header.getKey(), header.getValue());
代码示例来源:origin: co.cask.cdap/cdap-cli
output.printf("< %s %s\n", response.getResponseCode(), response.getResponseMessage());
for (Map.Entry<String, String> header : response.getHeaders().entries()) {
output.printf("< %s: %s\n", header.getKey(), header.getValue());
代码示例来源:origin: cdapio/cdap
String.format("Expected response code %d but got %d when trying to deploy app '%s' in namespace '%s'. " +
"Response message = '%s'", expectedCode, response.getResponseCode(),
application.getName(), namespace, response.getResponseMessage()));
内容来源于网络,如有侵权,请联系作者删除!