@@ -34,6 +34,9 @@ namespace RestSharp
3434 /// </summary>
3535 public partial class RestClient : IRestClient
3636 {
37+ // silverlight friendly way to get current version
38+ static readonly Version version = new AssemblyName ( Assembly . GetExecutingAssembly ( ) . FullName ) . Version ;
39+
3740 public IHttpFactory HttpFactory = new SimpleFactory < Http > ( ) ;
3841
3942 /// <summary>
@@ -57,12 +60,6 @@ public RestClient()
5760 AddHandler ( "text/xml" , new XmlDeserializer ( ) ) ;
5861 AddHandler ( "*" , new XmlDeserializer ( ) ) ;
5962
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 ( ) ;
6663 FollowRedirects = true ;
6764 }
6865
@@ -363,14 +360,16 @@ private void ConfigureHttp(IRestRequest request, IHttp http)
363360 }
364361
365362 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 )
368369 {
369- http . UserAgent = UserAgent ;
370+ http . Timeout = timeout ;
370371 }
371372
372- http . Timeout = request . Timeout == 0 ? Timeout : request . Timeout ;
373-
374373#if ! SILVERLIGHT
375374 http . FollowRedirects = FollowRedirects ;
376375#endif
0 commit comments