Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: PedroLamas/RestSharp
base: 358e646642
...
head fork: PedroLamas/RestSharp
compare: 8763a56ddb
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 2 contributors
Commits on Aug 05, 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
Commits on Aug 06, 2012
Pete Johanson petejohanson Merge pull request #309 from Haacked/timeout-fix
Fix problem with overriding request defaults
8763a56
Showing with 10 additions and 11 deletions.
  1. +10 −11 RestSharp/RestClient.cs
21 RestSharp/RestClient.cs
View
@@ -34,6 +34,9 @@ namespace RestSharp
/// </summary>
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<Http>();
/// <summary>
@@ -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

No commit comments for this range

Something went wrong with that request. Please try again.