public string StatusDescription { get; set; }
+ public long? RangeFrom { get; set; }
+ public long? RangeTo { get; set; }
public int Retries { get; set; }
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
if(Timeout>0)
request.Timeout = Timeout;
+
+ if (RangeFrom.HasValue)
+ {
+ if (RangeTo.HasValue)
+ request.AddRange(RangeFrom.Value, RangeTo.Value);
+ else
+ request.AddRange(RangeFrom.Value);
+ }
return request;
}
{
var response = (HttpWebResponse)base.GetWebResponse(request);
StatusCode = response.StatusCode;
- StatusDescription = response.StatusDescription;
+ LastModified=response.LastModified;
+ StatusDescription = response.StatusDescription;
return response;
}
catch (WebException exc)
- {
- if (exc.Response!=null && exc.Response.ContentLength > 0)
+ {
+ if (exc.Response!=null)
{
- string content = GetContent(exc.Response);
- Trace.TraceError(content);
+ var response = (exc.Response as HttpWebResponse);
+ if (response.StatusCode == HttpStatusCode.NotModified)
+ return response;
+ if (exc.Response.ContentLength > 0)
+ {
+ string content = GetContent(exc.Response);
+ Trace.TraceError(content);
+ }
}
throw;
}
}
+ public DateTime LastModified { get; private set; }
+
private static string GetContent(WebResponse webResponse)
{
string content;
return 0;
}, actualRetries);
- task.Wait();
+ try
+ {
+ task.Wait();
+ }
+ catch (AggregateException ex)
+ {
+ var exc = ex.InnerException;
+ if (exc is RetryException)
+ {
+ Trace.TraceError("[{0}] RETRY FAILED for {1} after {2} retries",method,address,retries);
+ }
+ else
+ {
+ Trace.TraceError("[{0}] FAILED for {1} with \n{2}", method, address, exc);
+ }
+ throw;
+
+ }
+ catch(Exception ex)
+ {
+ Trace.TraceError("[{0}] FAILED for {1} with \n{2}", method, address, ex);
+ throw;
+ }
}
/*private string RetryWithContent(string address, int retries, string method)
{
TimedOut = true;
if (retryCount == 0)
- {
- Trace.TraceError("[ERROR] Timed out too many times. {0}\n", e);
+ {
+ Trace.TraceError("[ERROR] Timed out too many times. \n{0}\n",e);
tcs.SetException(new RetryException("Timed out too many times.", e));
}
else