Archived
0

WebInterface: favicon

This commit is contained in:
2017-05-01 13:19:43 +03:00
parent 589df91151
commit 26352ef17e
3 changed files with 21 additions and 1 deletions

View File

@@ -1,5 +1,5 @@
group = 'asys' group = 'asys'
version = '0.18-SNAPSHOT' version = '0.18.1-SNAPSHOT'
buildscript { buildscript {
repositories { repositories {

View File

@@ -35,6 +35,11 @@ public class IndexHandler implements HttpHandler {
@Override @Override
public void handle(HttpExchange httpExchange) throws IOException { public void handle(HttpExchange httpExchange) throws IOException {
if (httpExchange.getRequestURI().getPath().equals("/favicon.ico")) {
favicon(httpExchange);
return;
}
String[] requestURIParts = getRequestURIParts(httpExchange.getRequestURI()); String[] requestURIParts = getRequestURIParts(httpExchange.getRequestURI());
if (requestURIParts.length > 0) { if (requestURIParts.length > 0) {
logger.debug("Module request: {}", requestURIParts[0]); logger.debug("Module request: {}", requestURIParts[0]);
@@ -79,4 +84,19 @@ public class IndexHandler implements HttpHandler {
return result; return result;
} }
} }
private void favicon(HttpExchange httpExchange) throws IOException {
httpExchange.getResponseHeaders().add("Context-Type","image/x-icon");
httpExchange.sendResponseHeaders(200, 0);
OutputStream outputStream = httpExchange.getResponseBody();
InputStream inputStream = getClass().getResourceAsStream("/static/favicon.ico");
final byte[] buffer = new byte[0x10000];
int len;
while((len = inputStream.read(buffer)) > 0) {
outputStream.write(buffer, 0, len);
}
outputStream.flush();
outputStream.close();
inputStream.close();
}
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 KiB