package org.springframework.integration.http.support;
"EEE, dd MMM yyyy HH:mm:ss zzz",
"EEE, dd-MMM-yy HH:mm:ss zzz",
"EEE MMM dd HH:mm:ss yyyy"
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(java.lang.String)
. The default is 'X-'.
- Parameters:
outboundHeaderNames
The outbound header names.
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(java.lang.String)
. The default is 'X-'.
- Parameters:
inboundHeaderNames
The inbound header names.
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
Assert.notNull(excludedOutboundStandardRequestHeaderNames, "'excludedOutboundStandardRequestHeaderNames' must not be null");
Provide header names from the list of standard headers that should be suppressed when
mapping inbound endopoint response headers.
- Parameters:
excludedInboundStandardResponseHeaderNames
the excludedStandardResponseHeaderNames to set
Assert.notNull(excludedInboundStandardResponseHeaderNames, "'excludedInboundStandardResponseHeaderNames' must not be null");
Sets the prefix to use with user-defined (non-standard) headers. Default is 'X-'.
- Parameters:
userDefinedHeaderPrefix
The user defined header prefix.
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).
for (String name : headerNames) {
logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value));
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).
for (String name : headerNames) {
logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value));
logger.debug(MessageFormat.format("setting headerName=[{0}], value={1}", name, value));
for (String headerName : headerNames) {
logger.debug(MessageFormat.format("headerName=[{0}] WILL NOT be mapped", headerName));
logger.debug(MessageFormat.format("headerName=[{0}] WILL NOT be mapped", headerName));
if (patterns != null && patterns.length > 0) {
for (String pattern : patterns) {
logger.debug(MessageFormat.format("headerName=[{0}] WILL be mapped, matched pattern={1}", headerName, pattern));
logger.debug(MessageFormat.format("headerName=[{0}] WILL be mapped, matched pattern={1}", headerName, pattern));
logger.debug(MessageFormat.format("headerName=[{0}] WILL be mapped, matched pattern={1}", headerName, pattern));
logger.debug(MessageFormat.format("headerName=[{0}] WILL NOT be mapped", headerName));
if (!CollectionUtils.isEmpty(values)) {
else if (type instanceof String) {
"Expected MediaType or String value for 'Accept' header value, but received: " + clazz);
else if (value instanceof String[]) {
else if (value instanceof String) {
"Expected MediaType or String value for 'Accept' header value, but received: " + clazz);
if (!CollectionUtils.isEmpty(values)) {
for (Object charset : values) {
else if (charset instanceof String) {
"Expected Charset or String value for 'Accept-Charset' header value, but received: " + clazz);
else if (value instanceof Charset[] || value instanceof String[]) {
for (Object charset : values) {
else if (charset instanceof String) {
else if (value instanceof Charset) {
else if (value instanceof String) {
for (String charset : charsets) {
"Expected Charset or String value for 'Accept-Charset' header value, but received: " + clazz);
if (!CollectionUtils.isEmpty(values)) {
for (Object method : values) {
else if (method instanceof String) {
"Expected HttpMethod or String value for 'Allow' header value, but received: " + clazz);
allowedMethods.add(next);
else if (value instanceof String || value instanceof String[]) {
"Expected HttpMethod or String value for 'Allow' header value, but received: " + clazz);
if (value instanceof String) {
"Expected String value for 'Cache-Control' header value, but received: " + clazz);
if (value instanceof Number) {
else if (value instanceof String) {
"Expected Number or String value for 'Content-Length' header value, but received: " + clazz);
else if (value instanceof String) {
"Expected MediaType or String value for 'Content-Type' header value, but received: " + clazz);
if (value instanceof Date) {
else if (value instanceof Number) {
else if (value instanceof String) {
"Expected Date, Number, or String value for 'Date' header value, but received: " + clazz);
if (value instanceof String) {
"Expected String value for 'ETag' header value, but received: " + clazz);
if (value instanceof Date) {
else if (value instanceof Number) {
else if (value instanceof String) {
"Expected Date, Number, or String value for 'Expires' header value, but received: " + clazz);
if (value instanceof Date) {
else if (value instanceof Number) {
else if (value instanceof String) {
"Expected Date, Number, or String value for 'If-Modified-Since' header value, but received: " + clazz);
String ifUnmodifiedSinceValue = null;
if (value instanceof Date) {
else if (value instanceof Number) {
else if (value instanceof String) {
ifUnmodifiedSinceValue = this.formatDate(longValue);
"Expected Date, Number, or String value for 'If-Unmodified-Since' header value, but received: " + clazz);
if (value instanceof String) {
else if (value instanceof String[]) {
if (!CollectionUtils.isEmpty(values)) {
"Expected String value for 'If-None-Match' header value, but received: " + clazz);
if (value instanceof Date) {
else if (value instanceof Number) {
else if (value instanceof String) {
"Expected Date, Number, or String value for 'Last-Modified' header value, but received: " + clazz);
if (value instanceof URI) {
else if (value instanceof String) {
"Expected URI or String value for 'Location' header value, but received: " + clazz);
if (value instanceof String) {
"Expected String value for 'Pragma' header value, but received: " + clazz);
else if (value instanceof String) {
else if (value instanceof String[]) {
else if (value instanceof Iterable<?>) {
convertedValue = (String) next;
if (StringUtils.hasText(convertedValue)){
logger.warn("Element of the header '" + name + "' with value '" + value +
"' will not be set since it is not a String and no Converter " +
"is available. Consider registering a Converter with ConversionService (e.g., <int:converter>)");
if (StringUtils.hasText(convertedValue)) {
target.set(name, convertedValue);
logger.warn("Header '" + name + "' with value '" + value +
"' will not be set since it is not a String and no Converter " +
"is available. Consider registering a Converter with ConversionService (e.g., <int:converter>)");
return (StringUtils.hasText(cacheControl)) ? cacheControl : null;
return (contentLength > -1) ? contentLength : null;
return (date > -1) ? date : null;
return (StringUtils.hasText(eTag)) ? eTag : null;
return (expires > -1) ? expires : null;
return (modifiedSince > -1) ? modifiedSince : null;
return (lastModified > -1) ? lastModified : null;
return (StringUtils.hasText(pragma)) ? pragma : null;
if (!ObjectUtils.isEmpty(values)) {
if (values.length == 1) {
target.put(name, values);
target.put(name, values[0]);
if (!CollectionUtils.isEmpty(values)) {
if (values.size() == 1) {
target.put(name, values);
else if (value != null) {
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.
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.