You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can create a PR to do this, but I wanted to run it by someone first to make sure it's acceptable, thanks.
Is your feature request related to a problem? Please describe.
If you are re-using a single HttpClient instance in your application (as is recommended by MS) and passing it into multiple instances of RestClient, that HttpClient instance may be modified by the RestSharp.RestClient.ConfigureHttpClient method. For example, the UserAgent header is added to the DefaultRequestHeaders property.
This may be an issue if your RestClient instances are for different APIs that expect different UserAgents. What happens is that you end up with multiple UserAgents and the API you're calling may fail to recognise it. Now, the API probably should be checking if the UserAgent contains a certain string, not equals, but I still think it would be better if the HttpClient instance was left untouched and the UserAgent set on the request message instead.
Describe the solution you'd like
ChangeRestSharp.RestClient.ConfigureHttpClient to only set the Timeout property (I think this is the only property that can't be set on each request)
Move the setting of UserAgent and ExpectContinue to RestSharp.RestClient.ExecuteRequestAsync and set them on the message.Headers property.
Describe alternatives you've considered
Use multiple instances of HttpClient, or ask for the API being called to use "contains" rather than "equals"
The text was updated successfully, but these errors were encountered:
I can create a PR to do this, but I wanted to run it by someone first to make sure it's acceptable, thanks.
Is your feature request related to a problem? Please describe.
If you are re-using a single HttpClient instance in your application (as is recommended by MS) and passing it into multiple instances of RestClient, that HttpClient instance may be modified by the
RestSharp.RestClient.ConfigureHttpClient
method. For example, the UserAgent header is added to the DefaultRequestHeaders property.This may be an issue if your RestClient instances are for different APIs that expect different UserAgents. What happens is that you end up with multiple UserAgents and the API you're calling may fail to recognise it. Now, the API probably should be checking if the UserAgent contains a certain string, not equals, but I still think it would be better if the HttpClient instance was left untouched and the UserAgent set on the request message instead.
Describe the solution you'd like
RestSharp.RestClient.ConfigureHttpClient
to only set the Timeout property (I think this is the only property that can't be set on each request)RestSharp.RestClient.ExecuteRequestAsync
and set them on the message.Headers property.Describe alternatives you've considered
Use multiple instances of HttpClient, or ask for the API being called to use "contains" rather than "equals"
The text was updated successfully, but these errors were encountered: