add getFirstHeader method to ElasticsearchResponse

This commit is contained in:
javanna 2016-05-18 11:40:20 +02:00 committed by Luca Cavanna
parent 1d06916b07
commit 16ab491016
1 changed files with 13 additions and 0 deletions

View File

@ -77,6 +77,19 @@ public class ElasticsearchResponse implements Closeable {
return response.getAllHeaders(); return response.getAllHeaders();
} }
/**
* Returns the value of the first header with a specified name of this message.
* If there is more than one matching header in the message the first element is returned.
* If there is no matching header in the message <code>null</code> is returned.
*/
public String getFirstHeader(String name) {
Header header = response.getFirstHeader(name);
if (header == null) {
return null;
}
return header.getValue();
}
/** /**
* Returns the response body available, null otherwise * Returns the response body available, null otherwise
* @see HttpEntity * @see HttpEntity