Skip to content

Commit

Permalink
Added extra check in getContentLength method. Long.parseLong(contentL…
Browse files Browse the repository at this point in the history
…engthHeader) was trowing exception in cash content-length header is present but its blank string
  • Loading branch information
kamleshgupshup committed Oct 10, 2019
1 parent 46240b5 commit 51450e2
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/org/mitre/dsmiley/httpproxy/ProxyServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 51450e2

Please sign in to comment.