@@ -107,6 +107,13 @@ private static class Builder
107107 private Optional <String > contentSha256 = Optional .empty ();
108108 private Set <ContentType > seenRequestPayloadContentTypes = new HashSet <>();
109109
110+ private static final Set <ContentType > CHUNKED_CONTENT_TYPES = Set .of (
111+ ContentType .AWS_CHUNKED ,
112+ ContentType .AWS_CHUNKED_IN_W3C_CHUNKED ,
113+ ContentType .W3C_CHUNKED ,
114+ ContentType .AWS_CHUNKED_UNSIGNED ,
115+ ContentType .AWS_CHUNKED_IN_W3C_CHUNKED_UNSIGNED );
116+
110117 private Builder () {}
111118
112119 private static Optional <String > parseHeaderValuesAsSingle (List <String > allValues )
@@ -203,16 +210,11 @@ private String requiredContentSha256()
203210
204211 private void assertContentTypeValid (ContentType actualContentType )
205212 {
206- if (actualContentType == ContentType .AWS_CHUNKED
207- || actualContentType == ContentType .AWS_CHUNKED_IN_W3C_CHUNKED
208- || actualContentType == ContentType .W3C_CHUNKED
209- || actualContentType == ContentType .AWS_CHUNKED_UNSIGNED
210- || actualContentType == ContentType .AWS_CHUNKED_IN_W3C_CHUNKED_UNSIGNED ) {
213+ if (CHUNKED_CONTENT_TYPES .contains (actualContentType )) {
211214 if (decodedContentLength .isEmpty ()) {
212215 throw new WebApplicationException (LENGTH_REQUIRED );
213216 }
214- String sha256 = requiredContentSha256 ();
215- if (actualContentType != ContentType .W3C_CHUNKED && !sha256 .startsWith ("STREAMING-" )) {
217+ if (actualContentType != ContentType .W3C_CHUNKED && !requiredContentSha256 ().startsWith ("STREAMING-" )) {
216218 throw new WebApplicationException (BAD_REQUEST );
217219 }
218220 }
0 commit comments