Package de.pangaea.metadataportal.utils
Class HttpClientUtils
- java.lang.Object
-
- de.pangaea.metadataportal.utils.HttpClientUtils
-
public final class HttpClientUtils extends Object
Some utility methods for decompressingHttpResponse
- Author:
- Uwe Schindler
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static InputStream
getDecompressingInputStream(HttpResponse<InputStream> resp)
Returns an InputStream which decodes with header "Content-Encoding"static void
sendCompressionHeaders(HttpRequest.Builder builder)
Sends "Accept-Encoding" header to ask server to compress result.static <T> HttpResponse<T>
sendHttpRequestWithRetry(HttpClient client, HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler)
Workaround for: https://stackoverflow.com/questions/55087292/how-to-handle-http-2-goaway-with-httpclient
-
-
-
Method Detail
-
getDecompressingInputStream
public static InputStream getDecompressingInputStream(HttpResponse<InputStream> resp) throws IOException
Returns an InputStream which decodes with header "Content-Encoding"- Throws:
IOException
-
sendCompressionHeaders
public static void sendCompressionHeaders(HttpRequest.Builder builder)
Sends "Accept-Encoding" header to ask server to compress result. The response can later be parsed withgetDecompressingInputStream(HttpResponse)
-
sendHttpRequestWithRetry
public static <T> HttpResponse<T> sendHttpRequestWithRetry(HttpClient client, HttpRequest request, HttpResponse.BodyHandler<T> responseBodyHandler) throws IOException
Workaround for: https://stackoverflow.com/questions/55087292/how-to-handle-http-2-goaway-with-httpclient- Throws:
IOException
-
-