本文整理了Java中co.cask.common.http.HttpRequest.getMethod()
方法的一些代码示例,展示了HttpRequest.getMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpRequest.getMethod()
方法的具体详情如下:
包路径:co.cask.common.http.HttpRequest
类名称:HttpRequest
方法名:getMethod
暂无
代码示例来源:origin: caskdata/cdap
/**
* Create a generic error message about a failure to make a specified request.
*
* @param request the request made
* @param body the request body if it should be in the error message
* @return a generic error message about the failure
*/
public String createErrorMessage(HttpRequest request, @Nullable String body) {
String headers = request.getHeaders() == null ?
"null" : Joiner.on(",").withKeyValueSeparator("=").join(request.getHeaders().entries());
return String.format("Error making request to %s service at %s while doing %s with headers %s%s.",
discoverableServiceName, request.getURL(), request.getMethod(),
headers, body == null ? "" : " and body " + body);
}
}
代码示例来源:origin: co.cask.cdap/cdap-common
/**
* Create a generic error message about a failure to make a specified request.
*
* @param request the request made
* @param body the request body if it should be in the error message
* @return a generic error message about the failure
*/
public String createErrorMessage(HttpRequest request, @Nullable String body) {
String headers = request.getHeaders() == null ?
"null" : Joiner.on(",").withKeyValueSeparator("=").join(request.getHeaders().entries());
return String.format("Error making request to %s service at %s while doing %s with headers %s%s.",
discoverableServiceName, request.getURL(), request.getMethod(),
headers, body == null ? "" : " and body " + body);
}
}
代码示例来源:origin: co.cask.cdap/cdap-notifications-api
private HttpResponse execute(HttpRequest request) throws NotificationFeedException {
try {
return remoteClient.execute(request);
} catch (IOException e) {
throw new NotificationFeedException(
String.format("Error connecting to Notification Feed Service at %s while doing %s",
request.getURL(), request.getMethod()));
}
}
}
代码示例来源:origin: co.cask.cdap/cdap-data-fabric
private HttpResponse doRequest(HttpRequest.Builder requestBuilder) throws DatasetManagementException {
HttpRequest request = addUserIdHeader(requestBuilder).build();
try {
LOG.trace("Executing {} {}", request.getMethod(), request.getURL().getPath());
HttpResponse response = remoteClient.execute(request);
LOG.trace("Executed {} {}", request.getMethod(), request.getURL().getPath());
return response;
} catch (ServiceUnavailableException e) { // thrown by RemoteClient in case of ConnectException
logThreadDump();
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw e;
} catch (SocketTimeoutException e) { // passed through by RemoteClient
logThreadDump();
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw new DatasetManagementException(remoteClient.createErrorMessage(request, null), e);
} catch (IOException e) { // other network exceptions
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw new DatasetManagementException(remoteClient.createErrorMessage(request, null), e);
} catch (Throwable e) { // anything unexpected
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw e;
}
}
代码示例来源:origin: cdapio/cdap
private HttpResponse doRequest(HttpRequest.Builder requestBuilder) throws DatasetManagementException {
HttpRequest request = addUserIdHeader(requestBuilder).build();
try {
LOG.trace("Executing {} {}", request.getMethod(), request.getURL().getPath());
HttpResponse response = remoteClient.execute(request);
LOG.trace("Executed {} {}", request.getMethod(), request.getURL().getPath());
return response;
} catch (ServiceUnavailableException e) { // thrown by RemoteClient in case of ConnectException
logThreadDump();
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw e;
} catch (SocketTimeoutException e) { // passed through by RemoteClient
logThreadDump();
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw new DatasetManagementException(remoteClient.createErrorMessage(request, null), e);
} catch (IOException e) { // other network exceptions
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw new DatasetManagementException(remoteClient.createErrorMessage(request, null), e);
} catch (Throwable e) { // anything unexpected
LOG.trace("Caught exception for {} {}", request.getMethod(), request.getURL().getPath(), e);
throw e;
}
}
内容来源于网络,如有侵权,请联系作者删除!