Permalink
Browse files

Fixed bug with /workbench/ path not redirecting

  • Loading branch information...
1 parent e59ab02 commit d57a90c49ee3edf24a1f79365dad923e8779e970 @veebs veebs committed Oct 8, 2011
@@ -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);
}
/**
@@ -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
*

0 comments on commit d57a90c

Please sign in to comment.