test for gui handler

This commit is contained in:
Andreas Penski 2020-05-11 09:07:40 +02:00
parent b02126c1cc
commit b164d71199
2 changed files with 20 additions and 3 deletions

View file

@ -29,10 +29,11 @@ abstract class BaseHandler implements HttpHandler {
os.close();
}
protected static void error(final HttpExchange httpExchange, final int statusCode, final String message) throws IOException {
protected static void error(final HttpExchange exchange, final int statusCode, final String message) throws IOException {
final byte[] bytes = message.getBytes();
httpExchange.sendResponseHeaders(statusCode, bytes.length);
final OutputStream os = httpExchange.getResponseBody();
exchange.getResponseHeaders().add("Content-Type", "text/plain");
exchange.sendResponseHeaders(statusCode, bytes.length);
final OutputStream os = exchange.getResponseBody();
os.write(bytes);
os.close();
}