Class HttpResponseDecorator.HeadersDecorator

  • All Implemented Interfaces:
    java.lang.Iterable<org.apache.http.Header>
    Enclosing class:
    HttpResponseDecorator

    public final class HttpResponseDecorator.HeadersDecorator
    extends java.lang.Object
    implements java.lang.Iterable<org.apache.http.Header>
    This class is returned by HttpResponseDecorator.getHeaders(). It provides three "Groovy" ways to access headers:
    Bracket notation
    resp.headers['Content-Type'] returns the Header instance
    Property notation
    resp.headers.'Content-Type' returns the header value
    Iterator methods
    Iterates over each Header:
    resp.headers.each {
       println "${it.name} : ${it.value}"
     }
    Since:
    0.5.0
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.http.Header getAt​(java.lang.String name)
      Access the named header value, using bracket form.
      java.util.Iterator iterator()
      Used to allow Groovy iteration methods over the response headers.
      protected java.lang.String propertyMissing​(java.lang.String name)
      Allow property-style access to header values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • HeadersDecorator

        public HeadersDecorator()
    • Method Detail

      • getAt

        public org.apache.http.Header getAt​(java.lang.String name)
        Access the named header value, using bracket form. For example, response.headers['Content-Encoding']
        Parameters:
        name - header name, e.g. Content-Type
        Returns:
        the Header, or null if it does not exist in this response
        See Also:
        HttpMessage.getFirstHeader(String)
      • propertyMissing

        protected java.lang.String propertyMissing​(java.lang.String name)
        Allow property-style access to header values. This is the same as getAt(String), except it simply returns the header's String value, instead of the Header object.
        Parameters:
        name - header name, e.g. Content-Type
        Returns:
        the Header, or null if it does not exist in this response
      • iterator

        public java.util.Iterator iterator()
        Used to allow Groovy iteration methods over the response headers. For example:
        response.headers.each {
           println "${it.name} : ${it.value}"
         }
        Specified by:
        iterator in interface java.lang.Iterable<org.apache.http.Header>