Package org.pentaho.di.core.util
Class HttpClientUtil
java.lang.Object
org.pentaho.di.core.util.HttpClientUtil
Utility class contained useful methods while working with
HttpClient
- Since:
- 06-27-2017
- Author:
- Yury_Bakhmutski
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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)
-
Constructor Details
-
HttpClientUtil
public HttpClientUtil()
-
-
Method Details
-
responseToString
- 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
- 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
-