Unclear when getContentLength will return 0 (zero)
- Dominant language
- Java
- Stars
- 325
- Forks
- 112
- PR merge metrics
- No merged PRs in 30d
Description
Currently, the JavaDoc of javax.servlet.ServletRequest.getContentLength() specifies
> Returns the length, in bytes, of the request body and made available by the input stream, or -1 if the length is not known (...)
This specification is clear for most cases:
* The returned value is -1 when the request has a Transfer-Encoding: chunked header.
* The returned value is the value of the Content-Length header when present in the request
However there are arguments what to return in case there is neither a Transfer-Encoding nor Content-Length in the request:
* The HTTP standard [RFC 7230 section 3.3.3](https://tools.ietf.org/html/rfc7230#section-3.3.3) specifies in that case "the message body length is zero".
* Tomcat 8.5 returns -1 in this case. A request to change the implementation to return zero ([Tomcat bug 60698](https://bz.apache.org/bugzilla/show_bug.cgi?id=60698)) was refused.
So, could you extend the JavaDoc to specify what the correct value is in the described case?
Contributor guide
Assessment
This issue has not been assessed yet.