Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug with /workbench/ path not redirecting

  • Loading branch information...
commit d57a90c49ee3edf24a1f79365dad923e8779e970 1 parent e59ab02
@veebs veebs authored
View
5 src/main/java/org/chililog/server/workbench/HttpRequestHandler.java
@@ -171,9 +171,8 @@ private void redirectToWorkBenchIndexHtml(MessageEvent e) {
HttpResponse response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.FOUND);
response.addHeader("Location", indexHTML);
- e.getChannel().write(response);
- e.getChannel().close(); // future.addListener(ChannelFutureListener.CLOSE);
-
+ ChannelFuture future = e.getChannel().write(response);
+ future.addListener(ChannelFutureListener.CLOSE);
}
/**
View
22 src/test/java/org/chililog/server/workbench/WorkbenchServiceTest.java
@@ -314,7 +314,27 @@ public void testStaticFileCompression() throws IOException, ParseException, Deco
return;
}
-
+
+ /**
+ * Check if we redirect to index.html successfully
+ *
+ * @throws IOException
+ */
+ @Test()
+ public void testRedirectToIndexHtml() throws IOException {
+ URL url = new URL("http://localhost:8989/workbench");
+ URLConnection conn = url.openConnection();
+ HashMap<String, String> headers = new HashMap<String, String>();
+ String responseCode = ApiUtils.getResponseHeaders(conn, headers);
+ assertEquals("HTTP/1.1 200 OK", responseCode);
+
+ url = new URL("http://localhost:8989/workbench/");
+ conn = url.openConnection();
+ headers = new HashMap<String, String>();
+ responseCode = ApiUtils.getResponseHeaders(conn, headers);
+ assertEquals("HTTP/1.1 200 OK", responseCode);
+ }
+
/**
* Check for ApiNotFound error. 404 Not Found
*
Please sign in to comment.
Something went wrong with that request. Please try again.