// -----------------------------------------------------------------------
// <copyright file="RestClient.cs" company="GRNet">
-// Copyright 2011 GRNET S.A. All rights reserved.
+// Copyright 2011-2012 GRNET S.A. All rights reserved.
//
// Redistribution and use in source and binary forms, with or
// without modification, are permitted provided that the following
TimedOut = false;
var webRequest = base.GetWebRequest(address);
var request = (HttpWebRequest)webRequest;
- request.ServicePoint.ConnectionLimit = 10;
+ request.ServicePoint.ConnectionLimit = 50;
if (IfModifiedSince.HasValue)
request.IfModifiedSince = IfModifiedSince.Value;
request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;
//The response stream must be copied to avoid affecting other code by disposing of the
//original response stream.
var stream = webResponse.GetResponseStream();
- using(var memStream=new MemoryStream((int) stream.Length))
+ using(var memStream=new MemoryStream())
using (var reader = new StreamReader(memStream))
{
stream.CopyTo(memStream);
}, actualRetries);
- var result = task.Result;
- return result;
+ try
+ {
+ var result = task.Result;
+ return result;
+
+ }
+ catch (AggregateException exc)
+ {
+ //If the task fails, propagate the original exception
+ if (exc.InnerException!=null)
+ throw exc.InnerException;
+ throw;
+ }
}
public void Head(string address,int retries=0)