Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 1 file changed
  • 0 comments
  • 2 contributors
Aug 04, 2012
Phil Haack Haacked Fix problem with setting request timeout
The original code could override the http.Timeout with
the value of 0 if the RestClient Timeout property was 0.

If RestClient.Timeout <= 0, it shouldn't override the
http.Timeout.
3e5282b
Phil Haack Haacked Don't overwrite http user agent with default
If a user overrides the IHttpFactory, RestCLient shouldn't overwrite the
default user agent with its own unless both the RestClient and the Http
instance both have not set the user agent to a proper value.
1912f1c
Aug 06, 2012
Pete Johanson petejohanson Merge pull request #309 from Haacked/timeout-fix
Fix problem with overriding request defaults
8763a56

Showing 1 changed file with 10 additions and 11 deletions. Show diff stats Hide diff stats

  1. +10 11 RestSharp/RestClient.cs
21 RestSharp/RestClient.cs
@@ -34,6 +34,9 @@ namespace RestSharp
34 34 /// </summary>
35 35 public partial class RestClient : IRestClient
36 36 {
  37 + // silverlight friendly way to get current version
  38 + static readonly Version version = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version;
  39 +
37 40 public IHttpFactory HttpFactory = new SimpleFactory<Http>();
38 41
39 42 /// <summary>
@@ -57,12 +60,6 @@ public RestClient()
57 60 AddHandler("text/xml", new XmlDeserializer());
58 61 AddHandler("*", new XmlDeserializer());
59 62
60   - // silverlight friendly way to get current version
61   - var assembly = Assembly.GetExecutingAssembly();
62   - AssemblyName assemblyName = new AssemblyName(assembly.FullName);
63   - var version = assemblyName.Version;
64   -
65   - UserAgent = "RestSharp " + version.ToString();
66 63 FollowRedirects = true;
67 64 }
68 65
@@ -363,14 +360,16 @@ private void ConfigureHttp(IRestRequest request, IHttp http)
363 360 }
364 361
365 362 http.Url = BuildUri(request);
366   -
367   - if(UserAgent.HasValue())
  363 +
  364 + var userAgent = UserAgent ?? http.UserAgent;
  365 + http.UserAgent = userAgent.HasValue() ? userAgent : "RestSharp " + version.ToString();
  366 +
  367 + var timeout = request.Timeout > 0 ? request.Timeout : Timeout;
  368 + if (timeout > 0)
368 369 {
369   - http.UserAgent = UserAgent;
  370 + http.Timeout = timeout;
370 371 }
371 372
372   - http.Timeout = request.Timeout == 0 ? Timeout : request.Timeout;
373   -
374 373 #if !SILVERLIGHT
375 374 http.FollowRedirects = FollowRedirects;
376 375 #endif

No commit comments for this range

Something went wrong with that request. Please try again.