Workaround for Synchronoss content-length limitation

Issue: SPR-17345
This commit is contained in:
Rossen Stoyanchev
2018-10-05 12:12:49 -04:00
parent 842297699d
commit 6fe8cb949f

View File

@@ -127,7 +127,7 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
MediaType mediaType = headers.getContentType();
Assert.state(mediaType != null, "No content type set");
int length = Math.toIntExact(headers.getContentLength());
int length = getContentLength(headers);
Charset charset = Optional.ofNullable(mediaType.getCharset()).orElse(StandardCharsets.UTF_8);
MultipartContext context = new MultipartContext(mediaType.toString(), length, charset.name());
@@ -165,7 +165,12 @@ public class SynchronossPartHttpMessageReader implements HttpMessageReader<Part>
listener.onError("Exception thrown while closing the parser", ex);
}
});
}
private int getContentLength(HttpHeaders headers) {
// Until this is fixed https://github.com/synchronoss/nio-multipart/issues/10
long length = headers.getContentLength();
return (int) length == length ? (int) length : -1;
}
}