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 String
buildHttpErrorMessage
(HttpURLConnection connection) Build error message from connection in case of failurestatic void
closeConnection
(HttpURLConnection connection) closeConnection.static String
encodeQueryParam
(String paramName, String paramValue) encodeQueryParam.static int
Getter for the fieldconnectTimeout
.static int
Getter for the fieldreadTimeout
.protected static HttpURLConnection
openConnection.static HttpURLConnection
openDeleteConnection
(URL url) openDeleteConnection.static HttpURLConnection
openPostConnection
(URL url) openPostConnection.static HttpURLConnection
openPostConnection
(URL url, Map<String, String> headers) openPostConnection.static String
readBody
(HttpURLConnection connection) readBody.static void
setConnectTimeout
(int connectTimeout) Setter for the fieldconnectTimeout
.static void
setReadTimeout
(int readTimeout) Setter for the fieldreadTimeout
.
-
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
openPostConnection.
- Parameters:
url
- aURL
object- Returns:
- a
HttpURLConnection
object - Throws:
IOException
- if any.
-
openPostConnection
public static HttpURLConnection openPostConnection(URL url, Map<String, String> headers) throws IOExceptionopenPostConnection.
- Parameters:
url
- aURL
objectheaders
- aMap
object- Returns:
- a
HttpURLConnection
object - Throws:
IOException
- if any.
-
openDeleteConnection
openDeleteConnection.
- Parameters:
url
- aURL
object- Returns:
- a
HttpURLConnection
object - Throws:
IOException
- if any.
-
openConnection
protected static HttpURLConnection openConnection(URL url, String requestMethod, Map<String, String> headers) throws IOExceptionopenConnection.
- Parameters:
url
- aURL
objectrequestMethod
- aString
objectheaders
- aMap
object- Returns:
- a
HttpURLConnection
object - Throws:
IOException
- if any.
-
readBody
readBody.
- Parameters:
connection
- aHttpURLConnection
object- Returns:
- a
String
object - Throws:
IOException
- if any.
-
encodeQueryParam
encodeQueryParam.
-
closeConnection
closeConnection.
- Parameters:
connection
- aHttpURLConnection
object
-
getConnectTimeout
public static int getConnectTimeout()Getter for the field
connectTimeout
.- Returns:
- a int
-
setConnectTimeout
public static void setConnectTimeout(int connectTimeout) Setter for the field
connectTimeout
.- Parameters:
connectTimeout
- a int
-
getReadTimeout
public static int getReadTimeout()Getter for the field
readTimeout
.- Returns:
- a int
-
setReadTimeout
public static void setReadTimeout(int readTimeout) Setter for the field
readTimeout
.- Parameters:
readTimeout
- a int
-