diff --git a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/HeadersInspectionHandler.java b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/HeadersInspectionHandler.java index 3c17324f0..8d5976bac 100644 --- a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/HeadersInspectionHandler.java +++ b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/HeadersInspectionHandler.java @@ -20,30 +20,30 @@ * The middleware responsible for inspecting the request and response headers */ public class HeadersInspectionHandler implements Interceptor { - /** - * Create a new instance of the HeadersInspectionHandler class with the default options - */ - public HeadersInspectionHandler() { - this(new HeadersInspectionOption()); - } - /** - * Create a new instance of the HeadersInspectionHandler class with the provided options - * @param options The options to use for the handler - */ - public HeadersInspectionHandler(@Nonnull final HeadersInspectionOption options) { - this.options = Objects.requireNonNull(options); - } - private final HeadersInspectionOption options; + /** + * Create a new instance of the HeadersInspectionHandler class with the default options + */ + public HeadersInspectionHandler() { + this(new HeadersInspectionOption()); + } + /** + * Create a new instance of the HeadersInspectionHandler class with the provided options + * @param options The options to use for the handler + */ + public HeadersInspectionHandler(@Nonnull final HeadersInspectionOption options) { + this.options = Objects.requireNonNull(options); + } + private final HeadersInspectionOption options; /** {@inheritDoc} */ @Nonnull - @Override - @SuppressWarnings("UnknownNullness") - public Response intercept(final Chain chain) throws IOException { + @Override + @SuppressWarnings("UnknownNullness") + public Response intercept(final Chain chain) throws IOException { Objects.requireNonNull(chain, "parameter chain cannot be null"); - Request request = chain.request(); - HeadersInspectionOption inspectionOption = request.tag(HeadersInspectionOption.class); - if(inspectionOption == null) { inspectionOption = options; } + Request request = chain.request(); + HeadersInspectionOption inspectionOption = request.tag(HeadersInspectionOption.class); + if(inspectionOption == null) { inspectionOption = options; } final Span span = ObservabilityHelper.getSpanForRequest(request, "HeadersInspectionHandler_Intercept"); Scope scope = null; if (span != null) { @@ -54,18 +54,18 @@ public Response intercept(final Chain chain) throws IOException { if (span != null) { request = request.newBuilder().tag(Span.class, span).build(); } - if (inspectionOption.getInspectRequestHeaders()) { - for(final Pair header : request.headers()) { - inspectionOption.getRequestHeaders().put(header.getFirst(), Set.of(header.getSecond())); - } - } + if (inspectionOption.getInspectRequestHeaders()) { + for(final Pair header : request.headers()) { + inspectionOption.getRequestHeaders().put(header.getFirst(), Set.of(header.getSecond())); + } + } final Response response = chain.proceed(request); - if (inspectionOption.getInspectResponseHeaders()) { - for(final Pair header : response.headers()) { - inspectionOption.getResponseHeaders().put(header.getFirst(), Set.of(header.getSecond())); - } - } - return response; + if (inspectionOption.getInspectResponseHeaders()) { + for(final Pair header : response.headers()) { + inspectionOption.getResponseHeaders().put(header.getFirst(), Set.of(header.getSecond())); + } + } + return response; } finally { if (scope != null) { scope.close(); @@ -74,6 +74,6 @@ public Response intercept(final Chain chain) throws IOException { span.end(); } } - } - + } + } diff --git a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/HeadersInspectionOption.java b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/HeadersInspectionOption.java index f084072a5..509691627 100644 --- a/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/HeadersInspectionOption.java +++ b/components/http/okHttp/src/main/java/com/microsoft/kiota/http/middleware/options/HeadersInspectionOption.java @@ -10,78 +10,78 @@ * The options to be passed to the headers inspection middleware. */ public class HeadersInspectionOption implements RequestOption { - private boolean inspectRequestHeaders; - /** - * Gets whether to inspect request headers - * @return Whether to inspect request headers - */ - public boolean getInspectRequestHeaders() { - return inspectRequestHeaders; - } - /** - * Sets whether to inspect request headers - * @param inspectRequestHeaders Whether to inspect request headers - */ - public void setInspectRequestHeaders(boolean inspectRequestHeaders) { - this.inspectRequestHeaders = inspectRequestHeaders; - } + private boolean inspectRequestHeaders; + /** + * Gets whether to inspect request headers + * @return Whether to inspect request headers + */ + public boolean getInspectRequestHeaders() { + return inspectRequestHeaders; + } + /** + * Sets whether to inspect request headers + * @param inspectRequestHeaders Whether to inspect request headers + */ + public void setInspectRequestHeaders(boolean inspectRequestHeaders) { + this.inspectRequestHeaders = inspectRequestHeaders; + } - private boolean inspectResponseHeaders; - /** - * Gets whether to inspect response headers - * @return Whether to inspect response headers - */ - public boolean getInspectResponseHeaders() { - return inspectResponseHeaders; - } - /** - * Sets whether to inspect response headers - * @param inspectResponseHeaders Whether to inspect response headers - */ - public void setInspectResponseHeaders(boolean inspectResponseHeaders) { - this.inspectResponseHeaders = inspectResponseHeaders; - } + private boolean inspectResponseHeaders; + /** + * Gets whether to inspect response headers + * @return Whether to inspect response headers + */ + public boolean getInspectResponseHeaders() { + return inspectResponseHeaders; + } + /** + * Sets whether to inspect response headers + * @param inspectResponseHeaders Whether to inspect response headers + */ + public void setInspectResponseHeaders(boolean inspectResponseHeaders) { + this.inspectResponseHeaders = inspectResponseHeaders; + } - private final RequestHeaders requestHeaders = new RequestHeaders(); - private final ResponseHeaders responseHeaders = new ResponseHeaders(); - /** - * Create default instance of headers inspection options, with default values of inspectRequestHeaders and inspectResponseHeaders. - */ - public HeadersInspectionOption() { - this(false, false); - } - /** - * Create an instance with provided values - * @param shouldInspectResponseHeaders Whether to inspect response headers - * @param shouldInspectRequestHeaders Whether to inspect request headers - */ - public HeadersInspectionOption(final boolean shouldInspectRequestHeaders, final boolean shouldInspectResponseHeaders) { - this.inspectResponseHeaders = shouldInspectResponseHeaders; - this.inspectRequestHeaders = shouldInspectRequestHeaders; - } - /** - * Get the request headers - * @return The request headers - */ - @Nonnull - public RequestHeaders getRequestHeaders() { - return this.requestHeaders; - } - /** - * Get the response headers - * @return The response headers - */ - @Nonnull - public ResponseHeaders getResponseHeaders() { - return this.responseHeaders; - } + private final RequestHeaders requestHeaders = new RequestHeaders(); + private final ResponseHeaders responseHeaders = new ResponseHeaders(); + /** + * Create default instance of headers inspection options, with default values of inspectRequestHeaders and inspectResponseHeaders. + */ + public HeadersInspectionOption() { + this(false, false); + } + /** + * Create an instance with provided values + * @param shouldInspectResponseHeaders Whether to inspect response headers + * @param shouldInspectRequestHeaders Whether to inspect request headers + */ + public HeadersInspectionOption(final boolean shouldInspectRequestHeaders, final boolean shouldInspectResponseHeaders) { + this.inspectResponseHeaders = shouldInspectResponseHeaders; + this.inspectRequestHeaders = shouldInspectRequestHeaders; + } + /** + * Get the request headers + * @return The request headers + */ + @Nonnull + public RequestHeaders getRequestHeaders() { + return this.requestHeaders; + } + /** + * Get the response headers + * @return The response headers + */ + @Nonnull + public ResponseHeaders getResponseHeaders() { + return this.responseHeaders; + } - /** {@inheritDoc} */ - @SuppressWarnings("unchecked") - @Override + /** {@inheritDoc} */ + @SuppressWarnings("unchecked") + @Override @Nonnull - public Class getType() { + public Class getType() { return (Class) HeadersInspectionOption.class; - } - + } + }