aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2012-04-29 08:06:46 +0000
committerAnton Tananaev <anton.tananaev@gmail.com>2012-04-29 08:06:46 +0000
commitf4798a290d97e824e0815b911682a3ede181c1e7 (patch)
treeac4b921a4059a3c7e3f1f7f4780428e7323f7d18
parent933639c9ae85204011b40540584bc2c2058e4a52 (diff)
downloadtrackermap-server-f4798a290d97e824e0815b911682a3ede181c1e7.tar.gz
trackermap-server-f4798a290d97e824e0815b911682a3ede181c1e7.tar.bz2
trackermap-server-f4798a290d97e824e0815b911682a3ede181c1e7.zip
-rw-r--r--nbproject/project.properties4
-rw-r--r--src/favicon.icobin0 -> 1150 bytes
-rw-r--r--src/org/traccar/http/WebServer.java25
3 files changed, 24 insertions, 5 deletions
diff --git a/nbproject/project.properties b/nbproject/project.properties
index cdd7324ea..aed63160a 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -44,12 +44,12 @@ javac.classpath=\
${file.reference.netty-3.4.1.Final.jar}:\
${file.reference.mysql-connector-java-5.1.19-bin.jar}:\
${file.reference.h2-1.3.166.jar}:\
- ${file.reference.jetty-continuation-8.1.3.v20120416.jar}:\
${file.reference.jetty-http-8.1.3.v20120416.jar}:\
${file.reference.jetty-io-8.1.3.v20120416.jar}:\
${file.reference.jetty-server-8.1.3.v20120416.jar}:\
${file.reference.jetty-util-8.1.3.v20120416.jar}:\
- ${file.reference.servlet-api-3.0.jar}
+ ${file.reference.servlet-api-3.0.jar}:\
+ ${file.reference.jetty-continuation-8.1.3.v20120416.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=true
diff --git a/src/favicon.ico b/src/favicon.ico
new file mode 100644
index 000000000..6fd696c25
--- /dev/null
+++ b/src/favicon.ico
Binary files differ
diff --git a/src/org/traccar/http/WebServer.java b/src/org/traccar/http/WebServer.java
index a99f6e11b..d42f8fe2c 100644
--- a/src/org/traccar/http/WebServer.java
+++ b/src/org/traccar/http/WebServer.java
@@ -41,6 +41,8 @@ public class WebServer {
private DataManager dataManager;
+ public static final int BUFFER_SIZE = 1024;
+
public WebHandler(DataManager dataManager) {
this.dataManager = dataManager;
}
@@ -53,7 +55,23 @@ public class WebServer {
InputStream in = this.getClass().getClassLoader().getResourceAsStream("index.html");
OutputStream out = response.getOutputStream();
- byte[] buffer = new byte[1024]; // Magic number
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int count;
+ while ((count = in.read(buffer)) != -1) {
+ out.write(buffer, 0, count);
+ }
+ out.flush();
+ }
+
+ public void handleIcon(String target,Request baseRequest,HttpServletRequest request,HttpServletResponse response)
+ throws IOException, ServletException {
+
+ response.setContentType("image/x-icon");
+
+ InputStream in = this.getClass().getClassLoader().getResourceAsStream("favicon.ico");
+ OutputStream out = response.getOutputStream();
+
+ byte[] buffer = new byte[BUFFER_SIZE];
int count;
while ((count = in.read(buffer)) != -1) {
out.write(buffer, 0, count);
@@ -90,8 +108,7 @@ public class WebServer {
Position position = i.next();
out.format("{'device_id':%d,'time':'%tF %tT','valid':%b,'latitude':%f,'longitude':%f,'speed':%f,'course':%f}",
position.getDeviceId(),
- position.getTime(),
- position.getTime(),
+ position.getTime(), position.getTime(),
position.getValid(),
position.getLatitude(),
position.getLongitude(),
@@ -121,6 +138,8 @@ public class WebServer {
{
if (target.equals("/") || target.equals("/index.html")) {
handleIndex(target, baseRequest, request, response);
+ } else if (target.matches("/favicon.ico")) {
+ handleIcon(target, baseRequest, request, response);
} else if (target.matches("/.+\\.json")) {
handleData(target, baseRequest, request, response);
} else {