From 51450e2a60288c7afacc1dc4174f3b6ed4459ae1 Mon Sep 17 00:00:00 2001 From: kamlesh patel Date: Thu, 10 Oct 2019 17:26:51 +0530 Subject: [PATCH] Added extra check in getContentLength method. Long.parseLong(contentLengthHeader) was trowing exception in cash content-length header is present but its blank string --- src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java b/src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java index 3e55f282..c7be071d 100644 --- a/src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java +++ b/src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java @@ -401,7 +401,8 @@ protected HttpRequest newProxyRequestWithEntity(String method, String proxyReque // Get the header value as a long in order to more correctly proxy very large requests private long getContentLength(HttpServletRequest request) { String contentLengthHeader = request.getHeader("Content-Length"); - if (contentLengthHeader != null) { + // To avoid header with blank value + if (contentLengthHeader != null && contentLengthHeader.trim().length() != 0) { return Long.parseLong(contentLengthHeader); } return -1L;