@@ -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
0 commit comments