Describe the bug
After upgrading from version 109.1 to 110.0 I noticed some of our logic is broken.
A typical use case for us is to add security headers during the authentication flow.
publicoverrideValueTaskAuthenticate(IRestClientclient,RestRequestrequest){request.AddOrUpdateParameter("X-Security-Param","generated-security-hash");returnValueTask.CompletedTask;}However, it doesn't work when sending requests with form data.
While investigating, I found that now when building RequestContent
| usingvarrequestContent=newRequestContent(this,request); |
for
HttpRequestMessage it adds only cached params
| varpostParameters=_parameters.GetContentParameters(_request.Method).ToArray(); |
but not ones added by Authenticator
| if(authenticator!=null)awaitauthenticator.Authenticate(this,request).ConfigureAwait(false); |
To Reproduce
publicclassRestWrapper:IAuthenticator{privatereadonlyRestClient_restClient;publicRestWrapper(){_restClient=newRestClient(newRestClientOptions{BaseUrl=newUri("https://localhost"),Authenticator=this});}publicValueTaskAuthenticate(IRestClientclient,RestRequestrequest){request.AddParameter("X-Security-Param","generated-security-hash");returnValueTask.CompletedTask;}publicvoidSendRequest(){vartestRequest=newRestRequest("api/v1/endpoint",Method.Post);testRequest.AddParameter("scope","test");_restClient.Execute(testRequest);}}newRestWrapper().SendRequest()// server failure - missing X-Security-Param
Describe the bug
After upgrading from version 109.1 to 110.0 I noticed some of our logic is broken.
A typical use case for us is to add security headers during the authentication flow.
However, it doesn't work when sending requests with form data.
While investigating, I found that now when building
RequestContentRestSharp/src/RestSharp/RestClient.Async.cs
Line 89 in edce8c9
for
HttpRequestMessageit adds only cached paramsRestSharp/src/RestSharp/Request/RequestContent.cs
Line 41 in edce8c9
but not ones added by Authenticator
RestSharp/src/RestSharp/RestClient.Async.cs
Line 92 in edce8c9
To Reproduce