Package groovyx.net.http
Class HttpResponseDecorator.HeadersDecorator
- java.lang.Object
-
- groovyx.net.http.HttpResponseDecorator.HeadersDecorator
-
- All Implemented Interfaces:
Iterable<org.apache.http.Header>
- Enclosing class:
- HttpResponseDecorator
public final class HttpResponseDecorator.HeadersDecorator extends Object implements Iterable<org.apache.http.Header>
This class is returned byHttpResponseDecorator.getHeaders(). It provides three "Groovy" ways to access headers:- Bracket notation
resp.headers['Content-Type']returns theHeaderinstance- Property notation
resp.headers.'Content-Type'returns theheader value- Iterator methods
- Iterates over each Header:
resp.headers.each { println "${it.name} : ${it.value}" }
- Since:
- 0.5.0
- Author:
- Tom Nichols
-
-
Constructor Summary
Constructors Constructor Description HeadersDecorator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.http.HeadergetAt(String name)Access the named header value, using bracket form.Iteratoriterator()Used to allow Groovy iteration methods over the response headers.protected StringpropertyMissing(String name)Allow property-style access to header values.
-
-
-
Method Detail
-
getAt
public org.apache.http.Header getAt(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, ornullif it does not exist in this response - See Also:
HttpMessage.getFirstHeader(String)
-
propertyMissing
protected String propertyMissing(String name)
Allow property-style access to header values. This is the same asgetAt(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, ornullif it does not exist in this response
-
-