Skip to content

Commit

Permalink
fix; interceptors order
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Oct 11, 2024
1 parent 2107738 commit bfde2a1
Showing 1 changed file with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,33 @@ private KiotaClientFactory() {}
}

final List<Interceptor> handlers = new ArrayList<>();
// orders matter as they are executed in a chain
// interceptors that only modify the request should be added first
// interceptors that read the response should be added last
handlers.add(
uriReplacementOption != null
? new UrlReplaceHandler(uriReplacementOption)
: new UrlReplaceHandler());
handlers.add(
retryHandlerOption != null
? new RetryHandler(retryHandlerOption)
: new RetryHandler());
handlers.add(
redirectHandlerOption != null
? new RedirectHandler(redirectHandlerOption)
: new RedirectHandler());
userAgentHandlerOption != null
? new UserAgentHandler(userAgentHandlerOption)
: new UserAgentHandler());
handlers.add(
parametersNameDecodingOption != null
? new ParametersNameDecodingHandler(parametersNameDecodingOption)
: new ParametersNameDecodingHandler());
handlers.add(
userAgentHandlerOption != null
? new UserAgentHandler(userAgentHandlerOption)
: new UserAgentHandler());
uriReplacementOption != null
? new UrlReplaceHandler(uriReplacementOption)
: new UrlReplaceHandler());
handlers.add(
headersInspectionHandlerOption != null
? new HeadersInspectionHandler(headersInspectionHandlerOption)
: new HeadersInspectionHandler());
handlers.add(
redirectHandlerOption != null
? new RedirectHandler(redirectHandlerOption)
: new RedirectHandler());
handlers.add(
retryHandlerOption != null
? new RetryHandler(retryHandlerOption)
: new RetryHandler());

return handlers.toArray(new Interceptor[0]);
}
Expand Down

0 comments on commit bfde2a1

Please sign in to comment.