From e02651741e455c8263c412cf9e14ed3e2d9834fe Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 27 Apr 2015 15:27:22 +1200 Subject: Handle null request in servlet --- src/org/traccar/http/DeviceServlet.java | 6 +++++- src/org/traccar/http/MainServlet.java | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/org/traccar/http/DeviceServlet.java b/src/org/traccar/http/DeviceServlet.java index 4f8f6961d..c994ed266 100644 --- a/src/org/traccar/http/DeviceServlet.java +++ b/src/org/traccar/http/DeviceServlet.java @@ -36,7 +36,9 @@ public class DeviceServlet extends HttpServlet { String command = req.getPathInfo(); - if (command.equals("/get")) { + if (command == null) { + resp.sendError(HttpServletResponse.SC_BAD_REQUEST); + } else if (command.equals("/get")) { get(req, resp); } else if (command.equals("/add")) { add(req, resp); @@ -44,6 +46,8 @@ public class DeviceServlet extends HttpServlet { update(req, resp); } else if (command.equals("/remove")) { remove(req, resp); + } else { + resp.sendError(HttpServletResponse.SC_BAD_REQUEST); } } diff --git a/src/org/traccar/http/MainServlet.java b/src/org/traccar/http/MainServlet.java index a3eae4e55..87769b780 100644 --- a/src/org/traccar/http/MainServlet.java +++ b/src/org/traccar/http/MainServlet.java @@ -49,7 +49,9 @@ public class MainServlet extends HttpServlet { String command = req.getPathInfo(); - if (command.equals("/async")) { + if (command == null) { + resp.sendError(HttpServletResponse.SC_BAD_REQUEST); + } else if (command.equals("/async")) { async(req.startAsync()); } else if (command.equals("/login")) { login(req, resp); -- cgit v1.2.3