类 AbstractMessageConverterMethodProcessor

java.lang.Object
cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodArgumentResolver
cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodProcessor
所有已实现的接口:
ParameterResolvingStrategy, ReturnValueHandler
直接已知子类:
HttpEntityMethodProcessor, RequestResponseBodyMethodProcessor

public abstract class AbstractMessageConverterMethodProcessor extends AbstractMessageConverterMethodArgumentResolver implements ReturnValueHandler
Extends AbstractMessageConverterMethodArgumentResolver with the ability to handle method return values by writing to the response with HttpMessageConverters.

write ActionMappingAnnotationHandler return value

从以下版本开始:
4.0 2022/1/23 12:30
作者:
Arjen Poutsma, Rossen Stoyanchev, Brian Clozel, Juergen Hoeller, Harry Yang
另请参阅:
  • 字段详细资料

    • log

      private static final cn.taketoday.logging.Logger log
    • SAFE_EXTENSIONS

      private static final Set<String> SAFE_EXTENSIONS
    • SAFE_MEDIA_BASE_TYPES

      private static final Set<String> SAFE_MEDIA_BASE_TYPES
    • ALL_APPLICATION_MEDIA_TYPES

      private static final List<MediaType> ALL_APPLICATION_MEDIA_TYPES
    • RESOURCE_REGION_LIST_TYPE

      private static final Type RESOURCE_REGION_LIST_TYPE
    • contentNegotiationManager

      private final ContentNegotiationManager contentNegotiationManager
    • problemMediaTypes

      private final List<MediaType> problemMediaTypes
    • safeExtensions

      private final HashSet<String> safeExtensions
  • 构造器详细资料

    • AbstractMessageConverterMethodProcessor

      protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters)
      Constructor with list of converters only.
    • AbstractMessageConverterMethodProcessor

      protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, @Nullable ContentNegotiationManager contentNegotiationManager)
      Constructor with list of converters and ContentNegotiationManager.
    • AbstractMessageConverterMethodProcessor

      protected AbstractMessageConverterMethodProcessor(List<HttpMessageConverter<?>> converters, @Nullable ContentNegotiationManager manager, @Nullable List<Object> requestResponseBodyAdvice)
      Constructor with list of converters and ContentNegotiationManager as well as request/response body advice instances.
  • 方法详细资料

    • writeWithMessageConverters

      protected <T> void writeWithMessageConverters(@Nullable T value, @Nullable cn.taketoday.core.MethodParameter returnType, RequestContext context) throws IOException, HttpMediaTypeNotAcceptableException, HttpMessageNotWritableException
      Writes the given return type to the given output message.
      参数:
      value - the value to write to the output message
      returnType - the type of the value
      context - the output message to write to and Used to inspect the Accept header.
      抛出:
      IOException - thrown in case of I/O errors
      HttpMediaTypeNotAcceptableException - thrown when the conditions indicated by the Accept header on the request cannot be met by the message converters
      HttpMessageNotWritableException - thrown if a given message cannot be written by a converter, or if the content-type chosen by the server has no compatible converter.
    • getReturnValueType

      protected Class<?> getReturnValueType(@Nullable Object value, @Nullable cn.taketoday.core.MethodParameter returnType)
      Return the type of the value to be written to the response. Typically this is a simple check via getClass on the value but if the value is null, then the return type needs to be examined possibly including generic type determination (e.g. ResponseEntity<T>).
    • isResourceType

      protected boolean isResourceType(@Nullable Object value, @Nullable cn.taketoday.core.MethodParameter returnType)
      Return whether the returned value or the declared return type extends Resource.
    • getGenericType

      private Type getGenericType(cn.taketoday.core.MethodParameter returnType)
      Return the generic type of the returnType (or of the nested type if it is an HttpEntity).
    • getProducibleMediaTypes

      protected List<MediaType> getProducibleMediaTypes(RequestContext request, Class<?> valueClass)
      Returns the media types that can be produced.
      另请参阅:
    • getProducibleMediaTypes

      protected List<MediaType> getProducibleMediaTypes(RequestContext request, Class<?> valueClass, @Nullable Type targetType)
      Returns the media types that can be produced. The resulting media types are:
      • The producible media types specified in the request mappings, or
      • Media types of configured converters that can write the specific return value, or
      • MediaType.ALL
    • getAcceptableMediaTypes

      private List<MediaType> getAcceptableMediaTypes(RequestContext request) throws HttpMediaTypeNotAcceptableException
      抛出:
      HttpMediaTypeNotAcceptableException
    • determineCompatibleMediaTypes

      private void determineCompatibleMediaTypes(List<MediaType> acceptableTypes, List<MediaType> producibleTypes, List<MediaType> mediaTypesToUse)
    • getMostSpecificMediaType

      private MediaType getMostSpecificMediaType(MediaType acceptType, MediaType produceType)
      Return the more specific of the acceptable and the producible media types with the q-value of the former.
    • addContentDispositionHeader

      private void addContentDispositionHeader(RequestContext request)
      Check if the path has a file extension and whether the extension is either on the list of safe extensions or explicitly registered. If not, and the status is in the 2xx range, a 'Content-Disposition' header with a safe attachment file name ("f.txt") is added to prevent RFD exploits.
    • notSafeExtension

      private boolean notSafeExtension(RequestContext request, @Nullable String extension)
    • resolveMediaType

      @Nullable private MediaType resolveMediaType(RequestContext request, String extension)
    • safeMediaType

      private boolean safeMediaType(MediaType mediaType)