Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use multi-part file size to set content length property #1156

Merged
merged 4 commits into from
Nov 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public void putMultipartContent(HttpServletRequest request, HttpServletResponse

ContentService contentService = contentServiceFactory.getContentService(storeResource);

headers.setContentLength(multiPart.getSize());

handleMultipart(request, response, headers,
contentService,
multiPart.getResource(),
Expand All @@ -144,6 +146,8 @@ public void postMultipartContent(HttpServletRequest request, HttpServletResponse

ContentService contentService = contentServiceFactory.getContentService(storeResource);

headers.setContentLength(multiPart.getSize());

handleMultipart(request, response, headers,
contentService,
new InputStreamResource(multiPart.getInputStream(), multiPart.getOriginalFilename()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.Describe;
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.FIt;
import static com.github.paulcwarren.ginkgo4j.Ginkgo4jDSL.It;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
Expand Down Expand Up @@ -94,6 +95,7 @@ public class StoreRestEndpointsIT {
assertThat(IOUtils.contentEquals(
new ByteArrayInputStream("New multi-part content".getBytes()),
r.getInputStream()), is(true));
assertThat(r.contentLength(), equalTo(Long.valueOf(content.length())));
});
});
Context("given a DELETE request to that path", () -> {
Expand Down Expand Up @@ -159,6 +161,7 @@ public class StoreRestEndpointsIT {
new ByteArrayInputStream(
"New multi-part content".getBytes()),
r.getInputStream()), is(true));
assertThat(r.contentLength(), equalTo(Long.valueOf(content.length())));
});
});
It("should delete the resource", () -> {
Expand Down Expand Up @@ -234,6 +237,7 @@ public class StoreRestEndpointsIT {
new ByteArrayInputStream(
"New multi-part content".getBytes()),
r.getInputStream()), is(true));
assertThat(r.contentLength(), equalTo(Long.valueOf(content.length())));
});
});
It("should delete the resource", () -> {
Expand Down