Class ResponseHeadersAsMetadata

java.lang.Object
com.adaptris.core.http.client.net.MetadataResponseHeaderImpl
com.adaptris.core.http.client.net.ResponseHeadersAsMetadata
All Implemented Interfaces:
ResponseHeaderHandler<HttpURLConnection>

public class ResponseHeadersAsMetadata extends MetadataResponseHeaderImpl
Concrete implementation of ResponseHeaderHandler which adds all the HTTP headers from the response as metadata to the AdaptrisMessage.

Because HttpURLConnection exposes headers as a List<String>; #setMetadataSeparator(String) is used as a separator between multiple items in the list to flatten the list into a single metadata value. The default value is the tab character ("\t").

This will include header fields where the key is null; this will end up as the string "null". HttpURLConnection exposes the HTTP status line (e.g. 200 HTTP/1.1 OK as a header field with no key so this will generally be what is associated with "null".

In the adapter configuration file this class is aliased as http-response-headers-as-metadata which is the preferred alternative to the fully qualified classname when building your configuration.

  • Constructor Details

    • ResponseHeadersAsMetadata

      public ResponseHeadersAsMetadata()
    • ResponseHeadersAsMetadata

      public ResponseHeadersAsMetadata(String prefix)
    • ResponseHeadersAsMetadata

      public ResponseHeadersAsMetadata(String prefix, String separator)
  • Method Details

    • addMetadata

      protected void addMetadata(Map<String,List<String>> headers, AdaptrisMessage reply)
      Specified by:
      addMetadata in class MetadataResponseHeaderImpl
    • getMetadataSeparator

      public String getMetadataSeparator()
    • setMetadataSeparator

      public void setMetadataSeparator(String s)
      Set the separator to be used when multiple headers should be associated with the same key.

      Because HttpURLConnection exposes headers as a List<String>; #setMetadataSeparator(String) is used as a separator between multiple items in the list to flatten the list into a single metadata value. The default value is the tab character ("\t").

      Parameters:
      s - the separator (default if not specified is "\t");