Add Javadoc for MockHttpServletResponse getContentLength method #31833
Labels
in: test
Issues in the test module
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: documentation
A documentation task
Milestone
spring-framework/spring-test/src/main/java/org/springframework/mock/web/MockHttpServletResponse.java
Lines 323 to 325 in a01c6d5
Leveraged this Class,
MockHttpServletResponse
, to write some tests and initially found the behavior of this getter,getContentLength
, confusing. After reaching this SO post and reading the process the poster followed in their comments, the source of my confusion became clear. That being, the content length was referring to the header value forContent-Length
, not the response's payload length.https://stackoverflow.com/questions/52005034/spring-boot-test-mockhttpservletresponse-getcontentlength-return-0-despite-of
Wondered if the team/maintainers would find any value in updating the docs with a hint that would help clarify to which "length" value the API is fetching... even though it is clearly included in the method name itself. With modern IDE's auto completing and bringing up tool tips, this might help draw the focus to the "content" part of the method name. Could extend this work to the Long version of the method as well.
Would be willing to raise a PR is there is consenses.
And not to wonder off on too much of a tangent here, perhaps a more direct method to calculate/verify the payload length might be a worthwhile contribution as well.
Thoughts?
Sorry for the double issue, originally posted from a non-personal account.
The text was updated successfully, but these errors were encountered: