diff options
| author | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-11-26 17:38:50 +0100 | 
|---|---|---|
| committer | Thomas Lenz <thomas.lenz@egiz.gv.at> | 2020-11-26 17:38:50 +0100 | 
| commit | 6aa0ba667a6608e34b19b31dba18673181c85a5f (patch) | |
| tree | e28cdb051f6189cd4034420265344d5faf38d0e3 /eaaf_core_utils/src/main | |
| parent | b6942870faa8aee99554de2a324634c92e8cbcaa (diff) | |
| download | EAAF-Components-6aa0ba667a6608e34b19b31dba18673181c85a5f.tar.gz EAAF-Components-6aa0ba667a6608e34b19b31dba18673181c85a5f.tar.bz2 EAAF-Components-6aa0ba667a6608e34b19b31dba18673181c85a5f.zip | |
add building block of a http ResponseHandler that returns the http status-code
Diffstat (limited to 'eaaf_core_utils/src/main')
| -rw-r--r-- | eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpUtils.java | 23 | 
1 files changed, 23 insertions, 0 deletions
| diff --git a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpUtils.java b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpUtils.java index 81ebe1fe..10555822 100644 --- a/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpUtils.java +++ b/eaaf_core_utils/src/main/java/at/gv/egiz/eaaf/core/impl/http/HttpUtils.java @@ -18,6 +18,7 @@  package at.gv.egiz.eaaf.core.impl.http; +import java.io.IOException;  import java.security.KeyManagementException;  import java.security.KeyStore;  import java.security.KeyStoreException; @@ -31,10 +32,15 @@ import javax.net.ssl.SSLContext;  import javax.servlet.http.HttpServletRequest;  import org.apache.commons.lang3.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.StatusLine; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.ResponseHandler;  import org.apache.http.conn.ssl.TrustAllStrategy;  import org.apache.http.ssl.SSLContextBuilder;  import org.apache.http.ssl.SSLContexts;  import org.apache.http.ssl.TrustStrategy; +import org.apache.http.util.EntityUtils;  import org.bouncycastle.jsse.provider.BouncyCastleJsseProvider;  import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException; @@ -47,6 +53,23 @@ public class HttpUtils {    private static final String ERROR_03 = "internal.httpclient.03"; +   +  /** +   * Simple Http response-handler that only give http status-code as result. +   *  +   * @return Status-Code of http response +   */ +  public static ResponseHandler<StatusLine> simpleStatusCodeResponseHandler() { +    return new ResponseHandler<StatusLine>() { +      @Override +      public StatusLine handleResponse(HttpResponse response) throws ClientProtocolException, IOException { +        EntityUtils.consumeQuietly(response.getEntity()); +        return response.getStatusLine(); + +      } +    }; +  } +      /**     * Helper method to retrieve server URL including context path.     * | 
