本文整理匯總了Java中org.apache.http.NoHttpResponseException.setStackTrace方法的典型用法代碼示例。如果您正苦於以下問題:Java NoHttpResponseException.setStackTrace方法的具體用法?Java NoHttpResponseException.setStackTrace怎麽用?Java NoHttpResponseException.setStackTrace使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.http.NoHttpResponseException
的用法示例。
在下文中一共展示了NoHttpResponseException.setStackTrace方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: execute
import org.apache.http.NoHttpResponseException; //導入方法依賴的package包/類
public CloseableHttpResponse execute(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware) throws IOException, HttpException {
Args.notNull(route, "HTTP route");
Args.notNull(request, "HTTP request");
Args.notNull(context, "HTTP context");
final Header[] origheaders = request.getAllHeaders();
for (int execCount = 1;; execCount++) {
try {
return this.requestExecutor.execute(route, request, context, execAware);
} catch (final IOException ex) {
if (execAware != null && execAware.isAborted()) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Request has been aborted");
}
throw ex;
}
if (retryHandler.retryRequest(ex, execCount, context)) {
if (Log.isLoggable(TAG, Log.INFO)) {
Log.i(TAG, "I/O exception ("+ ex.getClass().getName() +
") caught when processing request to "
+ route +
": "
+ ex.getMessage());
}
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, ex.getMessage(), ex);
}
if (!RequestEntityProxy.isRepeatable(request)) {
if (Log.isLoggable(TAG, Log.DEBUG)) {
Log.d(TAG, "Cannot retry non-repeatable request");
}
final NonRepeatableRequestException nreex = new NonRepeatableRequestException(
"Cannot retry request with a non-repeatable request entity");
nreex.initCause(ex);
}
request.setHeaders(origheaders);
if (Log.isLoggable(TAG, Log.INFO)) {
Log.i(TAG, "Retrying request to " + route);
}
} else {
if (ex instanceof NoHttpResponseException) {
final NoHttpResponseException updatedex = new NoHttpResponseException(
route.getTargetHost().toHostString() + " failed to respond");
updatedex.setStackTrace(ex.getStackTrace());
throw updatedex;
} else {
throw ex;
}
}
}
}
}
示例2: execute
import org.apache.http.NoHttpResponseException; //導入方法依賴的package包/類
@Override
public CloseableHttpResponse execute(
final HttpRoute route,
final HttpRequestWrapper request,
final HttpClientContext context,
final HttpExecutionAware execAware) throws IOException, HttpException {
Args.notNull(route, "HTTP route");
Args.notNull(request, "HTTP request");
Args.notNull(context, "HTTP context");
final Header[] origheaders = request.getAllHeaders();
for (int execCount = 1;; execCount++) {
try {
return this.requestExecutor.execute(route, request, context, execAware);
} catch (final IOException ex) {
if (execAware != null && execAware.isAborted()) {
this.log.debug("Request has been aborted");
throw ex;
}
if (retryHandler.retryRequest(ex, execCount, context)) {
if (this.log.isInfoEnabled()) {
this.log.info("I/O exception ("+ ex.getClass().getName() +
") caught when processing request to "
+ route +
": "
+ ex.getMessage());
}
if (this.log.isDebugEnabled()) {
this.log.debug(ex.getMessage(), ex);
}
if (!RequestEntityProxy.isRepeatable(request)) {
this.log.debug("Cannot retry non-repeatable request");
throw new NonRepeatableRequestException("Cannot retry request " +
"with a non-repeatable request entity", ex);
}
request.setHeaders(origheaders);
if (this.log.isInfoEnabled()) {
this.log.info("Retrying request to " + route);
}
} else {
if (ex instanceof NoHttpResponseException) {
final NoHttpResponseException updatedex = new NoHttpResponseException(
route.getTargetHost().toHostString() + " failed to respond");
updatedex.setStackTrace(ex.getStackTrace());
throw updatedex;
} else {
throw ex;
}
}
}
}
}