Skip to content

HttpRequest doesn't send parameters added in Authenticator #2061

Description

@hmG3

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions