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 983bce125f
commit 9064ef59f9

View File

@@ -138,7 +138,7 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
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());
@@ -176,7 +176,12 @@ public class SynchronossPartHttpMessageReader extends LoggingCodecSupport implem
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;
}
}