Skip to content

Commit bda2723

Browse files
committed
Correct charset determination in Synchronoss reader
1 parent bb74457 commit bda2723

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

spring-web/src/main/java/org/springframework/http/codec/multipart/SynchronossPartHttpMessageReader.java

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,12 @@ private static class SynchronossPartGenerator implements Consumer<FluxSink<Part>
121121
@Override
122122
public void accept(FluxSink<Part> emitter) {
123123

124-
MultipartContext context = createMultipartContext();
124+
HttpHeaders headers = this.inputMessage.getHeaders();
125+
MediaType mediaType = headers.getContentType();
126+
int length = Math.toIntExact(headers.getContentLength());
127+
Charset charset = Optional.ofNullable(mediaType.getCharset()).orElse(StandardCharsets.UTF_8);
128+
MultipartContext context = new MultipartContext(mediaType.toString(), length, charset.name());
129+
125130
NioMultipartParserListener listener = new FluxSinkAdapterListener(emitter, this.bufferFactory);
126131
NioMultipartParser parser = Multipart.multipart(context).forNIO(listener);
127132

@@ -152,16 +157,6 @@ public void accept(FluxSink<Part> emitter) {
152157
});
153158

154159
}
155-
156-
private MultipartContext createMultipartContext() {
157-
HttpHeaders headers = this.inputMessage.getHeaders();
158-
String contentType = headers.getContentType().toString();
159-
int contentLength = Math.toIntExact(headers.getContentLength());
160-
String charset = headers.getFirst(HttpHeaders.ACCEPT_CHARSET);
161-
return new MultipartContext(contentType, contentLength, charset);
162-
}
163-
164-
165160
}
166161
/**
167162
* Listen for parser output and adapt to {@code Flux<Sink<Part>>}.

0 commit comments

Comments
 (0)