smolnar82 commented on code in PR #638:
URL: https://github.com/apache/knox/pull/638#discussion_r999028813
##########
gateway-service-webhdfs/src/main/java/org/apache/knox/gateway/hdfs/dispatch/HdfsUIHaDispatch.java:
##########
@@ -26,6 +30,26 @@ public HdfsUIHaDispatch() throws ServletException {
super();
}
+ @Override
+ public URI getDispatchUrl(final HttpServletRequest request) {
+ String decoded;
+
+ try {
+ decoded = URLDecoder.decode(request.getRequestURL().toString(),
StandardCharsets.UTF_8.name() );
+ } catch (final Exception e) {
+ /* fall back in case of exception */
+ decoded = request.getRequestURL().toString();
+ }
+
+ final StringBuilder str = new StringBuilder(decoded);
+ final String query = request.getQueryString();
+ if ( query != null ) {
+ str.append('?');
+ str.append(query);
+ }
+ return URI.create(str.toString());
+ }
+
Review Comment:
@Flamingo93 - the internal logic of this method is a copy-paste of
`org.apache.knox.gateway.dispatch.URLDecodingDispatch.getDispatchUrl(HttpServletRequest)`.
I'd recommend to refactor this out in a util class and make sure this class
and `URLDecodingDispatch.getDispatchUrl(HttpServletRequest)` use the new util
class method.
We do not only avoid duplicated code, but the utility method can be unit
tested.
If I were you I'd create a new `URLUtil` class in `gateway-spi` in the
`org.apache.knox.gateway.util` package.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]