|
|
|
@ -1,5 +1,5 @@
@@ -1,5 +1,5 @@
|
|
|
|
|
/* |
|
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
|
* |
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -20,12 +20,13 @@ import java.util.List;
@@ -20,12 +20,13 @@ import java.util.List;
|
|
|
|
|
import org.springframework.core.codec.Encoder; |
|
|
|
|
import org.springframework.http.codec.HttpMessageReader; |
|
|
|
|
import org.springframework.http.codec.HttpMessageWriter; |
|
|
|
|
import org.springframework.http.codec.LoggingCodecSupport; |
|
|
|
|
import org.springframework.http.codec.ServerCodecConfigurer; |
|
|
|
|
import org.springframework.http.codec.ServerSentEventHttpMessageWriter; |
|
|
|
|
import org.springframework.http.codec.multipart.DefaultMultipartMessageReader; |
|
|
|
|
import org.springframework.http.codec.multipart.MultipartHttpMessageReader; |
|
|
|
|
import org.springframework.http.codec.multipart.SynchronossPartHttpMessageReader; |
|
|
|
|
import org.springframework.http.codec.multipart.Part; |
|
|
|
|
import org.springframework.lang.Nullable; |
|
|
|
|
import org.springframework.util.ClassUtils; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Default implementation of {@link ServerCodecConfigurer.ServerDefaultCodecs}. |
|
|
|
@ -34,34 +35,41 @@ import org.springframework.util.ClassUtils;
@@ -34,34 +35,41 @@ import org.springframework.util.ClassUtils;
|
|
|
|
|
*/ |
|
|
|
|
class ServerDefaultCodecsImpl extends BaseDefaultCodecs implements ServerCodecConfigurer.ServerDefaultCodecs { |
|
|
|
|
|
|
|
|
|
private static final boolean synchronossMultipartPresent = |
|
|
|
|
ClassUtils.isPresent("org.synchronoss.cloud.nio.multipart.NioMultipartParser", |
|
|
|
|
DefaultServerCodecConfigurer.class.getClassLoader()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
private Encoder<?> sseEncoder; |
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
private HttpMessageReader<Part> multipartReader; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void serverSentEventEncoder(Encoder<?> encoder) { |
|
|
|
|
this.sseEncoder = encoder; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void multipartReader(HttpMessageReader<Part> multipartReader) { |
|
|
|
|
this.multipartReader = multipartReader; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void extendTypedReaders(List<HttpMessageReader<?>> typedReaders) { |
|
|
|
|
if (synchronossMultipartPresent) { |
|
|
|
|
boolean enable = isEnableLoggingRequestDetails(); |
|
|
|
|
|
|
|
|
|
SynchronossPartHttpMessageReader partReader = new SynchronossPartHttpMessageReader(); |
|
|
|
|
partReader.setEnableLoggingRequestDetails(enable); |
|
|
|
|
typedReaders.add(partReader); |
|
|
|
|
HttpMessageReader<Part> partReader = getMultipartReader(); |
|
|
|
|
|
|
|
|
|
MultipartHttpMessageReader reader = new MultipartHttpMessageReader(partReader); |
|
|
|
|
reader.setEnableLoggingRequestDetails(enable); |
|
|
|
|
typedReaders.add(reader); |
|
|
|
|
boolean logRequestDetails = isEnableLoggingRequestDetails(); |
|
|
|
|
if (partReader instanceof LoggingCodecSupport) { |
|
|
|
|
((LoggingCodecSupport) partReader).setEnableLoggingRequestDetails(logRequestDetails); |
|
|
|
|
} |
|
|
|
|
typedReaders.add(partReader); |
|
|
|
|
|
|
|
|
|
MultipartHttpMessageReader reader = new MultipartHttpMessageReader(partReader); |
|
|
|
|
reader.setEnableLoggingRequestDetails(logRequestDetails); |
|
|
|
|
typedReaders.add(reader); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private HttpMessageReader<Part> getMultipartReader() { |
|
|
|
|
return this.multipartReader != null ? this.multipartReader : new DefaultMultipartMessageReader(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|