MockHttpServletRequestBuilder sets content-length
Closes gh-23978
This commit is contained in:
parent
4bbf2d5785
commit
f4c847b723
|
|
@ -687,6 +687,13 @@ public class MockHttpServletRequestBuilder
|
|||
}
|
||||
});
|
||||
|
||||
if (!ObjectUtils.isEmpty(this.content) &&
|
||||
!this.headers.containsKey(HttpHeaders.CONTENT_LENGTH) &&
|
||||
!this.headers.containsKey(HttpHeaders.TRANSFER_ENCODING)) {
|
||||
|
||||
request.addHeader(HttpHeaders.CONTENT_LENGTH, this.content.length);
|
||||
}
|
||||
|
||||
String query = this.url.getRawQuery();
|
||||
if (!this.queryParams.isEmpty()) {
|
||||
String s = UriComponentsBuilder.newInstance().queryParams(this.queryParams).build().encode().getQuery();
|
||||
|
|
|
|||
|
|
@ -389,6 +389,7 @@ public class MockHttpServletRequestBuilderTests {
|
|||
byte[] result = FileCopyUtils.copyToByteArray(request.getInputStream());
|
||||
|
||||
assertThat(result).isEqualTo(body);
|
||||
assertThat(request.getContentLength()).isEqualTo(body.length);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in New Issue