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 String
CONTENT_MD5
protected static DateTimeFormatter[]
DATE_FORMATS
static String
HTTP_REQUEST_HEADER_NAME_PATTERN
static String
HTTP_RESPONSE_HEADER_NAME_PATTERN
protected Log
logger
static String
REFRESH
-
Constructor Summary
Constructors Constructor Description DefaultHttpHeaderMapper()
-
Method Summary
Modifier and Type Method Description void
afterPropertiesSet()
protected static boolean
containsElementIgnoreCase(String[] headerNames, String name)
protected String
convertToString(Object value)
void
fromHeaders(MessageHeaders headers, HttpHeaders target)
Map from the integration MessageHeaders to an HttpHeaders instance.protected BeanFactory
getBeanFactory()
protected static long
getFirstDate(String headerValue, String headerName)
protected Object
getHttpHeader(HttpHeaders source, String name)
static DefaultHttpHeaderMapper
inboundMapper()
Factory method for creating a basic inbound mapper instance.static DefaultHttpHeaderMapper
outboundMapper()
Factory method for creating a basic outbound mapper instance.void
setBeanFactory(BeanFactory beanFactory)
void
setExcludedInboundStandardResponseHeaderNames(String... excludedInboundStandardResponseHeaderNames)
Provide header names from the list of standard headers that should be suppressed when mapping inbound endpoint response headers.void
setExcludedOutboundStandardRequestHeaderNames(String... excludedOutboundStandardRequestHeaderNames)
Provide header names from the list of standard headers that should be suppressed when mapping outbound endpoint request headers.void
setInboundHeaderNames(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.void
setOutboundHeaderNames(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 void
setupDefaultInboundMapper(DefaultHttpHeaderMapper mapper)
Subclasses can call this from a static inboundMapper() method to set up standard header mappings for an inbound mapper.protected static void
setupDefaultOutboundMapper(DefaultHttpHeaderMapper mapper)
Subclasses can call this from a static outboundMapper() method to set up standard header mappings for an outbound mapper.void
setUserDefinedHeaderPrefix(String userDefinedHeaderPrefix)
Sets the prefix to use with user-defined (non-standard) headers.protected boolean
shouldMapInboundHeader(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:
setBeanFactory
in 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:
afterPropertiesSet
in 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:
fromHeaders
in 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:
toHeaders
in 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.
-