@@ -33,6 +33,7 @@ namespace RestSharp;
3333/// <summary>
3434/// Client to translate RestRequests into Http requests and process response result
3535/// </summary>
36+ // ReSharper disable once ClassWithVirtualMembersNeverInherited.Global
3637public partial class RestClient : IRestClient {
3738 /// <summary>
3839 /// Content types that will be sent in the Accept header. The list is populated from the known serializers.
@@ -55,11 +56,6 @@ public string[] AcceptedContentTypes {
5556 /// <inheritdoc/>
5657 public DefaultParameters DefaultParameters { get ; }
5758
58- [ Obsolete ( "Use RestClientOptions.Authenticator instead" ) ]
59- public IAuthenticator ? Authenticator => Options . Authenticator ;
60-
61- // set => Options.Authenticator = value;
62-
6359 /// <summary>
6460 /// Creates an instance of RestClient using the provided <see cref="RestClientOptions"/>
6561 /// </summary>
@@ -226,7 +222,8 @@ public RestClient(
226222 : this ( new HttpClient ( handler , disposeHandler ) , true , configureRestClient , configureSerialization ) { }
227223
228224 static void ConfigureHttpClient ( HttpClient httpClient , RestClientOptions options ) {
229- if ( options . MaxTimeout > 0 ) httpClient . Timeout = TimeSpan . FromMilliseconds ( options . MaxTimeout ) ;
225+ // We will use Options.Timeout in ExecuteAsInternalAsync method
226+ httpClient . Timeout = Timeout . InfiniteTimeSpan ;
230227
231228 if ( options . Expect100Continue != null ) httpClient . DefaultRequestHeaders . ExpectContinue = options . Expect100Continue ;
232229 }
@@ -257,6 +254,7 @@ static void ConfigureHttpMessageHandler(HttpClientHandler handler, RestClientOpt
257254 handler . AllowAutoRedirect = options . FollowRedirects ;
258255
259256#if NET
257+ // ReSharper disable once InvertIf
260258 if ( ! OperatingSystem . IsBrowser ( ) && ! OperatingSystem . IsIOS ( ) && ! OperatingSystem . IsTvOS ( ) ) {
261259#endif
262260 if ( handler . SupportsProxy ) handler . Proxy = options . Proxy ;
@@ -276,12 +274,12 @@ void ConfigureSerializers(ConfigureSerialization? configureSerialization) {
276274 }
277275
278276 void ConfigureDefaultParameters ( RestClientOptions options ) {
279- if ( options . UserAgent != null ) {
280- if ( ! options . AllowMultipleDefaultParametersWithSameName
281- && DefaultParameters . Any ( parameter => parameter . Type == ParameterType . HttpHeader && parameter . Name == KnownHeaders . UserAgent ) )
282- DefaultParameters . RemoveParameter ( KnownHeaders . UserAgent , ParameterType . HttpHeader ) ;
283- DefaultParameters . AddParameter ( Parameter . CreateParameter ( KnownHeaders . UserAgent , options . UserAgent , ParameterType . HttpHeader ) ) ;
284- }
277+ if ( options . UserAgent == null ) return ;
278+
279+ if ( ! options . AllowMultipleDefaultParametersWithSameName
280+ && DefaultParameters . Any ( parameter => parameter . Type == ParameterType . HttpHeader && parameter . Name == KnownHeaders . UserAgent ) )
281+ DefaultParameters . RemoveParameter ( KnownHeaders . UserAgent , ParameterType . HttpHeader ) ;
282+ DefaultParameters . AddParameter ( Parameter . CreateParameter ( KnownHeaders . UserAgent , options . UserAgent , ParameterType . HttpHeader ) ) ;
285283 }
286284
287285 readonly bool _disposeHttpClient ;
0 commit comments