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

HttpPipelineBuilder proposal #43504

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions sdk/clientcore/core/spotbugs-exclude.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Class name="io.clientcore.core.http.models.HttpRequest" />
<Class name="io.clientcore.core.http.models.RequestOptions" />
<Class name="io.clientcore.core.http.pipeline.HttpLoggingPolicy" />
<Class name="io.clientcore.core.http.pipeline.HttpPipelineBuilder" />
<Class name="io.clientcore.core.http.pipeline.HttpPipelineNextPolicy" />
<Class name="io.clientcore.core.http.pipeline.HttpRetryPolicy" />
<Class name="io.clientcore.core.implementation.http.HttpPipelineCallState" />
Expand All @@ -31,18 +32,18 @@
<Class name="io.clientcore.core.implementation.http.serializer.CompositeSerializer" />
<Class name="io.clientcore.core.implementation.util.DateTimeRfc1123" />
<Class name="io.clientcore.core.implementation.util.InternalContext" />
<Class name="io.clientcore.core.implementation.util.JsonSerializer" />
<Class name="io.clientcore.core.implementation.util.Providers" />
<Class name="io.clientcore.core.implementation.util.SliceInputStream" />
<Class name="io.clientcore.core.implementation.util.StreamUtil" />
<Class name="io.clientcore.core.implementation.util.XmlSerializer" />
<Class name="io.clientcore.core.serialization.xml.XmlReader" />
<Class name="io.clientcore.core.shared.HttpClientTests" />
<Class name="io.clientcore.core.util.SharedExecutorService" />
<Class name="io.clientcore.core.util.binarydata.FileBinaryData" />
<Class name="io.clientcore.core.util.binarydata.InputStreamBinaryData" />
<Class name="io.clientcore.core.util.binarydata.ListByteBufferBinaryData" />
<Class name="io.clientcore.core.util.configuration.Configuration" />
<Class name="io.clientcore.core.implementation.util.JsonSerializer" />
<Class name="io.clientcore.core.implementation.util.XmlSerializer" />
</Or>
</Match>
<Match>
Expand Down Expand Up @@ -93,13 +94,17 @@
</Match>
<Match>
<Bug pattern="DMI_RANDOM_USED_ONLY_ONCE" />
<Class name="io.clientcore.core.util.TestUtils" />
<Or>
<Class name="io.clientcore.core.http.pipeline.HttpPipelinePolicyTests$SyncPolicy" />
<Class name="io.clientcore.core.util.TestUtils" />
</Or>
</Match>
<Match>
<Bug pattern="DM_CONVERT_CASE" />
<Or>
<Class name="io.clientcore.core.http.exception.HttpExceptionType" />
<Class name="io.clientcore.core.http.models.HttpHeaderName" />
<Class name="io.clientcore.core.http.pipeline.HttpPipelineBuilder" />
<Class name="io.clientcore.core.util.ServerSentEventUtils" />
<Class name="io.clientcore.core.util.auth.AuthUtils" />
</Or>
Expand All @@ -110,6 +115,7 @@
<Class name="io.clientcore.core.http.RestProxyTests" />
<Class name="io.clientcore.core.http.client.DefaultHttpClientTest" />
<Class name="io.clientcore.core.http.client.SimpleBasicAuthHttpProxyServer" />
<Class name="io.clientcore.core.http.pipeline.HttpPipelinePolicyTests$SyncPolicy" />
<Class name="io.clientcore.core.implementation.http.rest.RestProxyImplTests" />
<Class name="io.clientcore.core.implementation.serializer.AdditionalPropertiesSerializerTests" />
<Class name="io.clientcore.core.implementation.serializer.BinaryDataSerializationTests" />
Expand Down Expand Up @@ -259,11 +265,11 @@
<Bug pattern="PZLA_PREFER_ZERO_LENGTH_ARRAYS" />
<Or>
<Class name="io.clientcore.core.implementation.util.Base64Uri" />
<Class name="io.clientcore.core.implementation.util.JsonSerializer" />
<Class name="io.clientcore.core.implementation.util.XmlSerializer" />
<Class name="io.clientcore.core.serialization.json.implementation.DefaultJsonReader" />
<Class name="io.clientcore.core.util.TestUtils" />
<Class name="io.clientcore.core.implementation.util.JsonSerializer" />
<Class name="io.clientcore.core.util.serializer.MockSerializer" />
<Class name="io.clientcore.core.implementation.util.XmlSerializer" />
</Or>
</Match>
<Match>
Expand Down Expand Up @@ -324,6 +330,7 @@
<Match>
<Bug pattern="SIC_INNER_SHOULD_BE_STATIC_ANON" />
<Or>
<Class name="io.clientcore.core.http.pipeline.HttpPipelinePolicyTests" />
<Class name="io.clientcore.core.http.pipeline.HttpPipelineTests" />
<Class name="io.clientcore.core.http.pipeline.RedirectPolicyTest" />
<Class name="io.clientcore.core.http.pipeline.RetryPolicyTests" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package io.clientcore.core.http.pipeline;

/**
* This class is exactly the same as {@link HttpPipelinePolicy} but exists to provide a standard parent class for all
* credential policies and to differentiate them from other forms of {@link HttpPipelinePolicy}s.
*/
public abstract class HttpCredentialPolicy implements HttpPipelinePolicy {
static final String NAME = "credential";

/**
* Creates an instance of {@link HttpCredentialPolicy}.
*/
public HttpCredentialPolicy() {
}

@Override
public final String getName() {
return NAME;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* The pipeline policy that handles logging of HTTP requests and responses.
*/
public class HttpLoggingPolicy implements HttpPipelinePolicy {
public final class HttpLoggingPolicy implements HttpPipelinePolicy {
private static final int MAX_BODY_LOG_SIZE = 1024 * 16;
private static final String REDACTED_PLACEHOLDER = "REDACTED";
private static final ClientLogger LOGGER = new ClientLogger(HttpLoggingPolicy.class);
Expand All @@ -47,6 +47,8 @@ public class HttpLoggingPolicy implements HttpPipelinePolicy {
private static final String REQUEST_LOG_MESSAGE = "HTTP request";
private static final String RESPONSE_LOG_MESSAGE = "HTTP response";

static final String NAME = "logging";

/**
* Creates an HttpLoggingPolicy with the given log configurations.
*
Expand Down Expand Up @@ -111,6 +113,11 @@ public Response<?> process(HttpRequest httpRequest, HttpPipelineNextPolicy next)
}
}

@Override
public String getName() {
return NAME;
}

private ClientLogger.LoggingEventBuilder createBasicLoggingContext(ClientLogger logger, ClientLogger.LogLevel level,
HttpRequest request) {
ClientLogger.LoggingEventBuilder log = logger.atLevel(level);
Expand Down
Loading
Loading