Skip to content

Commit

Permalink
Get the status servlet working again.
Browse files Browse the repository at this point in the history
  • Loading branch information
shs96c committed Jun 24, 2018
1 parent c15cdbc commit 0f49c42
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openqa.grid.web.servlet.console.ConsoleServlet;
import org.openqa.selenium.internal.BuildInfo;
import org.openqa.selenium.json.Json;
import org.openqa.selenium.json.JsonOutput;

import java.io.BufferedReader;
import java.io.IOException;
Expand Down Expand Up @@ -104,12 +105,17 @@ protected void process(HttpServletRequest request, HttpServletResponse response)
if (in == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
final String json = new Json().toJson(servletConfig);
final String jsonUtf8 = new String(json.getBytes(), "UTF-8");
StringBuilder jsonBuilder = new StringBuilder();
try (JsonOutput out = new Json().newOutput(jsonBuilder)) {
out.setPrettyPrint(false).write(servletConfig);
}

final String json = jsonBuilder.toString();

final String htmlTemplate =
new BufferedReader(new InputStreamReader(in, "UTF-8")).lines().collect(Collectors.joining("\n"));
final String updatedTemplate =
htmlTemplate.replace(HELPER_SERVLET_TEMPLATE_CONFIG_JSON_VAR, jsonUtf8);
htmlTemplate.replace(HELPER_SERVLET_TEMPLATE_CONFIG_JSON_VAR, json);

response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
Expand Down

0 comments on commit 0f49c42

Please sign in to comment.