diff --git a/RestSharp/RestClient.cs b/RestSharp/RestClient.cs index 2a0e873dc..15c9bfa2b 100644 --- a/RestSharp/RestClient.cs +++ b/RestSharp/RestClient.cs @@ -34,6 +34,9 @@ namespace RestSharp /// public partial class RestClient : IRestClient { + // silverlight friendly way to get current version + static readonly Version version = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version; + public IHttpFactory HttpFactory = new SimpleFactory(); /// @@ -57,12 +60,6 @@ public RestClient() AddHandler("text/xml", new XmlDeserializer()); AddHandler("*", new XmlDeserializer()); - // silverlight friendly way to get current version - var assembly = Assembly.GetExecutingAssembly(); - AssemblyName assemblyName = new AssemblyName(assembly.FullName); - var version = assemblyName.Version; - - UserAgent = "RestSharp " + version.ToString(); FollowRedirects = true; } @@ -363,14 +360,16 @@ private void ConfigureHttp(IRestRequest request, IHttp http) } http.Url = BuildUri(request); - - if(UserAgent.HasValue()) + + var userAgent = UserAgent ?? http.UserAgent; + http.UserAgent = userAgent.HasValue() ? userAgent : "RestSharp " + version.ToString(); + + var timeout = request.Timeout > 0 ? request.Timeout : Timeout; + if (timeout > 0) { - http.UserAgent = UserAgent; + http.Timeout = timeout; } - http.Timeout = request.Timeout == 0 ? Timeout : request.Timeout; - #if !SILVERLIGHT http.FollowRedirects = FollowRedirects; #endif