diff options
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/traccar/web/OverrideFilter.java | 40 | ||||
-rw-r--r-- | src/main/java/org/traccar/web/ResponseWrapper.java | 3 |
2 files changed, 23 insertions, 20 deletions
diff --git a/src/main/java/org/traccar/web/OverrideFilter.java b/src/main/java/org/traccar/web/OverrideFilter.java index e6e02514c..70eb80a67 100644 --- a/src/main/java/org/traccar/web/OverrideFilter.java +++ b/src/main/java/org/traccar/web/OverrideFilter.java @@ -50,30 +50,32 @@ public class OverrideFilter implements Filter { chain.doFilter(request, wrappedResponse); byte[] bytes = wrappedResponse.getCapture(); - if (wrappedResponse.getContentType() != null && wrappedResponse.getContentType().contains("text/html") - || ((HttpServletRequest) request).getPathInfo().endsWith("manifest.json")) { + if (bytes != null) { + if (wrappedResponse.getContentType() != null && wrappedResponse.getContentType().contains("text/html") + || ((HttpServletRequest) request).getPathInfo().endsWith("manifest.json")) { - Server server; - try { - server = permissionsServiceProvider.get().getServer(); - } catch (StorageException e) { - throw new RuntimeException(e); - } + Server server; + try { + server = permissionsServiceProvider.get().getServer(); + } catch (StorageException e) { + throw new RuntimeException(e); + } - String title = server.getString("title", "Traccar"); - String description = server.getString("description", "Traccar GPS Tracking System"); - String colorPrimary = server.getString("colorPrimary", "#1a237e"); + String title = server.getString("title", "Traccar"); + String description = server.getString("description", "Traccar GPS Tracking System"); + String colorPrimary = server.getString("colorPrimary", "#1a237e"); - String alteredContent = new String(wrappedResponse.getCapture()) - .replace("${title}", title) - .replace("${description}", description) - .replace("${colorPrimary}", colorPrimary); + String alteredContent = new String(wrappedResponse.getCapture()) + .replace("${title}", title) + .replace("${description}", description) + .replace("${colorPrimary}", colorPrimary); - response.setContentLength(alteredContent.length()); - response.getOutputStream().write(alteredContent.getBytes()); + response.setContentLength(alteredContent.length()); + response.getOutputStream().write(alteredContent.getBytes()); - } else { - response.getOutputStream().write(bytes); + } else { + response.getOutputStream().write(bytes); + } } } diff --git a/src/main/java/org/traccar/web/ResponseWrapper.java b/src/main/java/org/traccar/web/ResponseWrapper.java index 7c06b67b8..c6179a33e 100644 --- a/src/main/java/org/traccar/web/ResponseWrapper.java +++ b/src/main/java/org/traccar/web/ResponseWrapper.java @@ -75,8 +75,9 @@ public class ResponseWrapper extends HttpServletResponseWrapper { public byte[] getCapture() throws IOException { if (output != null) { output.close(); + return capture.toByteArray(); } - return capture.toByteArray(); + return null; } } |