Skip to content

Commit

Permalink
fix(proxy): Beans with special characters not working in proxy url
Browse files Browse the repository at this point in the history
fix #2505
  • Loading branch information
abkieling committed Aug 23, 2018
1 parent 650a015 commit 0339e07
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
Expand Up @@ -78,7 +78,7 @@ public ProxyDetails(HttpServletRequest httpServletRequest) {
}

public ProxyDetails(String pathInfo) {
hostAndPort = pathInfo;
hostAndPort = pathInfo.replace(" ", "%20");

if (hostAndPort == null) {
return;
Expand Down
Expand Up @@ -201,7 +201,7 @@ protected void service(HttpServletRequest servletRequest, HttpServletResponse se
try {
targetUriObj = new URI(proxyRequestUri);
} catch (URISyntaxException e) {
LOG.debug("URL '{}' is not valid: {}", proxyRequestUri, e.getMessage());
LOG.error("URL '{}' is not valid: {}", proxyRequestUri, e.getMessage());
servletResponse.setStatus(HttpServletResponse.SC_NOT_FOUND);
return;
}
Expand Down
Expand Up @@ -73,6 +73,7 @@ public void testPathInfoWithPort() throws Exception {
when(mockReq.getPathInfo()).thenReturn("/localhost/90/jolokia/");

ProxyDetails details = new ProxyDetails(mockReq);

assertEquals("getUserName()", null, details.getUserName());
assertEquals("getPassword()", null, details.getPassword());
assertEquals("getHost()", "localhost", details.getHost());
Expand All @@ -83,6 +84,16 @@ public void testPathInfoWithPort() throws Exception {
assertEquals("getFullProxyUrl()", "http://localhost:90/jolokia/", details.getFullProxyUrl());
}

@Test
public void testPathInfoWithWhitespace() throws Exception {
HttpServletRequest mockReq = mock(HttpServletRequest.class);
when(mockReq.getPathInfo()).thenReturn("/http/localhost/10001/jolokia/read/java.lang:type=MemoryManager,name=Metaspace Manager/Name");

ProxyDetails details = new ProxyDetails(mockReq);

assertEquals("getFullProxyUrl()", "http://localhost:10001/jolokia/read/java.lang:type=MemoryManager,name=Metaspace%20Manager/Name", details.getFullProxyUrl());
}

@Test
public void testDefaultPort() throws Exception {
HttpServletRequest mockReq = mock(HttpServletRequest.class);
Expand Down
3 changes: 3 additions & 0 deletions hawtio-war/pom.xml
Expand Up @@ -205,6 +205,9 @@
<script>${project.basedir}/etc/security.cli</script>
</scripts>
</beforeDeployment>
<javaOpts>
<javaOpt>-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8787</javaOpt>
</javaOpts>
</configuration>
</plugin>

Expand Down

0 comments on commit 0339e07

Please sign in to comment.