Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review HttpRequest Body Reading in HttpPipelinePolicies #14917

Closed
alzimmermsft opened this issue Sep 8, 2020 · 1 comment
Closed

Review HttpRequest Body Reading in HttpPipelinePolicies #14917

alzimmermsft opened this issue Sep 8, 2020 · 1 comment
Assignees
Labels
Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. common common module used by all azure SDKs (e.g. client, Mgmt) pillar-performance The issue is related to performance, one of our core engineering pillars.
Milestone

Comments

@alzimmermsft
Copy link
Member

Review HttpPipelinePolicy operations on how they consume HttpRequest bodies. Particularly, ensure that side-affect operations, such as authorization calculations, don't leave the ByteBuffer in a consumed state (where a call to remaining() is mutated). In cases where the body buffers need to be read a duplicate of the body buffer should be created and consumed to ensure the body is left in an unmodified state when the HttpClient goes to send the request.

@alzimmermsft alzimmermsft added Client This issue points to a problem in the data-plane of the library. Azure.Core azure-core common common module used by all azure SDKs (e.g. client, Mgmt) labels Sep 8, 2020
@alzimmermsft alzimmermsft added the pillar-performance The issue is related to performance, one of our core engineering pillars. label Jan 19, 2021
@alzimmermsft alzimmermsft removed their assignment May 27, 2021
@alzimmermsft alzimmermsft added this to the [2021] August milestone May 27, 2021
@mssfang mssfang self-assigned this Jun 23, 2021
@mssfang
Copy link
Member

mssfang commented Jun 30, 2021

Checked all exisiting classes that implements HttpPipelinePolicy. All ByteBuffer that used in the request is in the unmodifiable state.

Report:

Not ByteBuffer read operation Policies:

  • AddDatePolicy, AddHeadersFromContextPolicy, AddHeadersPolicy, ArmChallengeAuthenticationPolicy, AzureKeyCredentialPolicy, AzureSasCredentialPolicy, BearerTokenAuthenticationChallengePolicy,
    BearerTokenAuthenticationPolicy, CookiePolicy, HostPolicy, OpenTelemetryHttpPolicy, PortPolicy, ProtocolPolicy, RecordNetworkCallPolicy, RequestIdPolicy, TimeoutPolicy, UserAgentPolicy

Policies that use the ByteBuffer:

  • HttpLoggingPolicy::writeBufferToBodyStream // already duplicate the ByteBuffer.
  • RetryPolicy:
  return httpResponse.getBody()
                            .ignoreElements() // since we ignore the elements, duplicate the byteBuffer doesn't needed here.
                            .then(attemptAsync(context, next, originalHttpRequest, tryCount + 1)
                                .delaySubscription(delayDuration));

@mssfang mssfang closed this as completed Jun 30, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Apr 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Azure.Core azure-core Client This issue points to a problem in the data-plane of the library. common common module used by all azure SDKs (e.g. client, Mgmt) pillar-performance The issue is related to performance, one of our core engineering pillars.
Projects
Status: Done
Development

No branches or pull requests

2 participants