Package org.pac4j.core.util
Class HttpUtils
java.lang.Object
org.pac4j.core.util.HttpUtils
This class provides utility functions to deal with opening connections,
building error messages and closing connections, etc.
- Since:
- 1.8.0
- Author:
- Misagh Moayyed
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringbuildHttpErrorMessage(HttpURLConnection connection) Build error message from connection in case of failurestatic voidcloseConnection(HttpURLConnection connection) static StringencodeQueryParam(String paramName, String paramValue) static intstatic intprotected static HttpURLConnectionstatic HttpURLConnectionopenDeleteConnection(URL url) static HttpURLConnectionopenPostConnection(URL url) static HttpURLConnectionopenPostConnection(URL url, Map<String, String> headers) static StringreadBody(HttpURLConnection connection) static voidsetConnectTimeout(int connectTimeout) static voidsetReadTimeout(int readTimeout)
-
Method Details
-
buildHttpErrorMessage
Build error message from connection in case of failure- Parameters:
connection- HttpURLConnection- Returns:
- String by combining response code, message and error stream
- Throws:
IOException- an IO exception
-
openPostConnection
- Throws:
IOException
-
openPostConnection
public static HttpURLConnection openPostConnection(URL url, Map<String, String> headers) throws IOException- Throws:
IOException
-
openDeleteConnection
- Throws:
IOException
-
openConnection
protected static HttpURLConnection openConnection(URL url, String requestMethod, Map<String, String> headers) throws IOException- Throws:
IOException
-
readBody
- Throws:
IOException
-
encodeQueryParam
-
closeConnection
-
getConnectTimeout
public static int getConnectTimeout() -
setConnectTimeout
public static void setConnectTimeout(int connectTimeout) -
getReadTimeout
public static int getReadTimeout() -
setReadTimeout
public static void setReadTimeout(int readTimeout)
-