RestSharp 107 RestClient Options Non-Public

400 views
Skip to first unread message

Mathew Osmanski

unread,
Mar 10, 2022, 10:14:34 AM3/10/22
to RestSharp
Is there a reason why the RestClient options aren't public? I am not able to easily read or set them in my app once the client has been configured.

Thanks, Mat

Mathew Osmanski

unread,
Mar 10, 2022, 4:10:41 PM3/10/22
to RestSharp
using System;
using RestSharp;

RestClientOptions rco = new RestClientOptions("http://somebaseurl.com");
            rco.Timeout = 10000;
            rco.UseDefaultCredentials = true;

            var restClient = new RestClient(rco);
            restClient.Op

Alexey Zimarev

unread,
Mar 11, 2022, 3:27:27 AM3/11/22
to RestSharp
You cannot change the options after the instance is constructed, because those options are used for a wrapped HttpClient and HttpMessageHandler instance. Changing the options would require to re-create those, which is a no-go since it will make the client not thread safe. There's, however, a discussion, to make the options public but read-only. That's something that can be done.
Reply all
Reply to author
Forward
0 new messages