Skip to content

Commit 4410978

Browse files
Added extra check in getContentLength method. Long.parseLong(contentLengthHeader) was throwing exception in case content-length header is present but its blank string
1 parent 46240b5 commit 4410978

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,8 @@ protected HttpRequest newProxyRequestWithEntity(String method, String proxyReque
401401
// Get the header value as a long in order to more correctly proxy very large requests
402402
private long getContentLength(HttpServletRequest request) {
403403
String contentLengthHeader = request.getHeader("Content-Length");
404-
if (contentLengthHeader != null) {
404+
// To avoid header with blank value
405+
if (contentLengthHeader != null && contentLengthHeader.trim().length() != 0) {
405406
return Long.parseLong(contentLengthHeader);
406407
}
407408
return -1L;

0 commit comments

Comments
 (0)