Exemplo n.º 1
0
 /// <exception cref="System.IO.IOException"></exception>
 /// <exception cref="Apache.Http.HttpException"></exception>
 public virtual CloseableHttpResponse Execute(HttpRoute route, HttpRequestWrapper
                                              request, HttpClientContext context, HttpExecutionAware execAware)
 {
     Args.NotNull(route, "HTTP route");
     Args.NotNull(request, "HTTP request");
     Args.NotNull(context, "HTTP context");
     Header[] origheaders = request.GetAllHeaders();
     for (int execCount = 1; ; execCount++)
     {
         try
         {
             return(this.requestExecutor.Execute(route, request, context, execAware));
         }
         catch (IOException ex)
         {
             if (execAware != null && execAware.IsAborted())
             {
                 this.log.Debug("Request has been aborted");
                 throw;
             }
             if (retryHandler.RetryRequest(ex, execCount, context))
             {
                 if (this.log.IsInfoEnabled())
                 {
                     this.log.Info("I/O exception (" + ex.GetType().FullName + ") caught when processing request: "
                                   + ex.Message);
                 }
                 if (this.log.IsDebugEnabled())
                 {
                     this.log.Debug(ex.Message, ex);
                 }
                 if (!Proxies.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);
                 this.log.Info("Retrying request");
             }
             else
             {
                 throw;
             }
         }
     }
 }