Class DefaultHttpHeaderMapper
java.lang.Object
org.springframework.integration.http.support.DefaultHttpHeaderMapper
- All Implemented Interfaces:
Aware,BeanFactoryAware,InitializingBean,HeaderMapper<HttpHeaders>
public class DefaultHttpHeaderMapper extends Object implements HeaderMapper<HttpHeaders>, BeanFactoryAware, InitializingBean
Default
HeaderMapper implementation for HTTP.- Since:
- 2.0
- Author:
- Mark Fisher, Jeremy Grelle, Oleg Zhurakousky, Gunnar Hillert, Gary Russell, Artem Bilan
-
Field Summary
Fields Modifier and Type Field Description static StringCONTENT_MD5protected static DateTimeFormatter[]DATE_FORMATSstatic StringHTTP_REQUEST_HEADER_NAME_PATTERNstatic StringHTTP_RESPONSE_HEADER_NAME_PATTERNprotected Logloggerstatic StringREFRESH -
Constructor Summary
Constructors Constructor Description DefaultHttpHeaderMapper() -
Method Summary
Modifier and Type Method Description voidafterPropertiesSet()protected static booleancontainsElementIgnoreCase(String[] headerNames, String name)protected StringconvertToString(Object value)voidfromHeaders(MessageHeaders headers, HttpHeaders target)Map from the integration MessageHeaders to an HttpHeaders instance.protected BeanFactorygetBeanFactory()protected static longgetFirstDate(String headerValue, String headerName)protected ObjectgetHttpHeader(HttpHeaders source, String name)static DefaultHttpHeaderMapperinboundMapper()Factory method for creating a basic inbound mapper instance.static DefaultHttpHeaderMapperoutboundMapper()Factory method for creating a basic outbound mapper instance.voidsetBeanFactory(BeanFactory beanFactory)voidsetExcludedInboundStandardResponseHeaderNames(String... excludedInboundStandardResponseHeaderNames)Provide header names from the list of standard headers that should be suppressed when mapping inbound endpoint response headers.voidsetExcludedOutboundStandardRequestHeaderNames(String... excludedOutboundStandardRequestHeaderNames)Provide header names from the list of standard headers that should be suppressed when mapping outbound endpoint request headers.voidsetInboundHeaderNames(String... inboundHeaderNamesArg)Provide the header names that should be mapped from an HTTP request (for inbound adapters) or HTTP response (for outbound adapters) to a Spring Integration Message's headers.voidsetOutboundHeaderNames(String... outboundHeaderNames)Provide the header names that should be mapped to an HTTP request (for outbound adapters) or HTTP response (for inbound adapters) from a Spring Integration Message's headers.protected static voidsetupDefaultInboundMapper(DefaultHttpHeaderMapper mapper)Subclasses can call this from a static inboundMapper() method to set up standard header mappings for an inbound mapper.protected static voidsetupDefaultOutboundMapper(DefaultHttpHeaderMapper mapper)Subclasses can call this from a static outboundMapper() method to set up standard header mappings for an outbound mapper.voidsetUserDefinedHeaderPrefix(String userDefinedHeaderPrefix)Sets the prefix to use with user-defined (non-standard) headers.protected booleanshouldMapInboundHeader(String headerName)Map<String,Object>toHeaders(HttpHeaders source)Map from an HttpHeaders instance to integration MessageHeaders.
-
Field Details
-
logger
-
CONTENT_MD5
- See Also:
- Constant Field Values
-
REFRESH
- See Also:
- Constant Field Values
-
HTTP_REQUEST_HEADER_NAME_PATTERN
- See Also:
- Constant Field Values
-
HTTP_RESPONSE_HEADER_NAME_PATTERN
- See Also:
- Constant Field Values
-
DATE_FORMATS
-
-
Constructor Details
-
DefaultHttpHeaderMapper
public DefaultHttpHeaderMapper()
-
-
Method Details
-
setBeanFactory
- Specified by:
setBeanFactoryin interfaceBeanFactoryAware- Throws:
BeansException
-
getBeanFactory
-
setOutboundHeaderNames
Provide the header names that should be mapped to an HTTP request (for outbound adapters) or HTTP response (for inbound adapters) from a Spring Integration Message's headers. The values can also contain simple wildcard patterns (e.g. "foo*" or "*foo") to be matched.Any non-standard headers will be prefixed with the value specified by
setUserDefinedHeaderPrefix(String). The default is 'X-'.- Parameters:
outboundHeaderNames- The outbound header names.
-
setInboundHeaderNames
Provide the header names that should be mapped from an HTTP request (for inbound adapters) or HTTP response (for outbound adapters) to a Spring Integration Message's headers. The values can also contain simple wildcard patterns (e.g. "foo*" or "*foo") to be matched.This will match the header name directly or, for non-standard HTTP headers, it will match the header name prefixed with the value specified by
setUserDefinedHeaderPrefix(String). The default for that is an empty String.- Parameters:
inboundHeaderNamesArg- The inbound header names.
-
setExcludedOutboundStandardRequestHeaderNames
public void setExcludedOutboundStandardRequestHeaderNames(String... excludedOutboundStandardRequestHeaderNames)Provide header names from the list of standard headers that should be suppressed when mapping outbound endpoint request headers.- Parameters:
excludedOutboundStandardRequestHeaderNames- the excludedStandardRequestHeaderNames to set
-
setExcludedInboundStandardResponseHeaderNames
public void setExcludedInboundStandardResponseHeaderNames(String... excludedInboundStandardResponseHeaderNames)Provide header names from the list of standard headers that should be suppressed when mapping inbound endpoint response headers.- Parameters:
excludedInboundStandardResponseHeaderNames- the excludedStandardResponseHeaderNames to set
-
setUserDefinedHeaderPrefix
Sets the prefix to use with user-defined (non-standard) headers. The default is an empty string.- Parameters:
userDefinedHeaderPrefix- The user defined header prefix.
-
afterPropertiesSet
public void afterPropertiesSet()- Specified by:
afterPropertiesSetin interfaceInitializingBean
-
fromHeaders
Map from the integration MessageHeaders to an HttpHeaders instance. Depending on which type of adapter is using this mapper, the HttpHeaders might be for an HTTP request (outbound adapter) or for an HTTP response (inbound adapter).- Specified by:
fromHeadersin interfaceHeaderMapper<HttpHeaders>
-
toHeaders
Map from an HttpHeaders instance to integration MessageHeaders. Depending on which type of adapter is using this mapper, the HttpHeaders might be from an HTTP request (inbound adapter) or from an HTTP response (outbound adapter).- Specified by:
toHeadersin interfaceHeaderMapper<HttpHeaders>
-
getHttpHeader
-
shouldMapInboundHeader
-
convertToString
-
containsElementIgnoreCase
-
getFirstDate
-
outboundMapper
Factory method for creating a basic outbound mapper instance. This will map all standard HTTP request headers when sending an HTTP request, and it will map all standard HTTP response headers when receiving an HTTP response.- Returns:
- The default outbound mapper.
-
setupDefaultOutboundMapper
Subclasses can call this from a static outboundMapper() method to set up standard header mappings for an outbound mapper.- Parameters:
mapper- the mapper.
-
inboundMapper
Factory method for creating a basic inbound mapper instance. This will map all standard HTTP request headers when receiving an HTTP request, and it will map all standard HTTP response headers when sending an HTTP response.- Returns:
- The default inbound mapper.
-
setupDefaultInboundMapper
Subclasses can call this from a static inboundMapper() method to set up standard header mappings for an inbound mapper.- Parameters:
mapper- the mapper.
-