Package org.pentaho.di.core.util
Class HttpClientUtil
- java.lang.Object
-
- org.pentaho.di.core.util.HttpClientUtil
-
public class HttpClientUtil extends Object
Utility class contained useful methods while working withHttpClient
- Since:
- 06-27-2017
- Author:
- Yury_Bakhmutski
-
-
Constructor Summary
Constructors Constructor Description HttpClientUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.http.client.protocol.HttpClientContext
createPreemptiveBasicAuthentication(String host, int port, String user, String password)
Returns context with AuthCache or null in case of any exception was thrown.static org.apache.http.client.protocol.HttpClientContext
createPreemptiveBasicAuthentication(String host, int port, String user, String password, String schema)
Returns context with AuthCache or null in case of any exception was thrown.static byte[]
responseToByteArray(org.apache.http.HttpResponse response)
static InputStream
responseToInputStream(org.apache.http.HttpResponse response)
static String
responseToString(org.apache.http.HttpResponse response)
static String
responseToString(org.apache.http.HttpResponse response, Charset charset)
static String
responseToString(org.apache.http.HttpResponse response, Charset charset, boolean decode)
-
-
-
Method Detail
-
responseToString
public static String responseToString(org.apache.http.HttpResponse response) throws IOException
- Parameters:
response
- the httpresponse for processing- Returns:
- HttpEntity in String representation using "UTF-8" encoding
- Throws:
IOException
-
responseToString
public static String responseToString(org.apache.http.HttpResponse response, Charset charset) throws IOException
- Parameters:
response
- the httpresponse for processingcharset
- the charset used for getting HttpEntity- Returns:
- HttpEntity in decoded String representation using provided charset
- Throws:
IOException
-
responseToString
public static String responseToString(org.apache.http.HttpResponse response, Charset charset, boolean decode) throws IOException
- Parameters:
response
- the httpresponse for processingcharset
- the charset used for getting HttpEntitydecode
- determines if the result should be decoded or not- Returns:
- HttpEntity in String representation using provided charset
- Throws:
IOException
-
responseToInputStream
public static InputStream responseToInputStream(org.apache.http.HttpResponse response) throws IOException
- Throws:
IOException
-
responseToByteArray
public static byte[] responseToByteArray(org.apache.http.HttpResponse response) throws IOException
- Throws:
IOException
-
createPreemptiveBasicAuthentication
public static org.apache.http.client.protocol.HttpClientContext createPreemptiveBasicAuthentication(String host, int port, String user, String password, String schema)
Returns context with AuthCache or null in case of any exception was thrown.- Parameters:
host
-port
-user
-password
-schema
-- Returns:
HttpClientContext
-
createPreemptiveBasicAuthentication
public static org.apache.http.client.protocol.HttpClientContext createPreemptiveBasicAuthentication(String host, int port, String user, String password)
Returns context with AuthCache or null in case of any exception was thrown. Use "http" schema.- Parameters:
host
-port
-user
-password
-- Returns:
HttpClientContext
-
-