java.lang.Object
com.erudika.para.server.utils.HttpUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
getCookieValue
(jakarta.servlet.http.HttpServletRequest req, String name) Reads a cookie.static String
getStateParam
(String name, jakarta.servlet.http.HttpServletRequest req) Reads a cookie.static boolean
isAjaxRequest
(jakarta.servlet.http.HttpServletRequest request) Checks if a request comes from JavaScript.static void
removeStateParam
(String name, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Deletes a cookie.static void
setAuthCookie
(String name, String value, boolean httpOnly, int maxAge, String sameSite, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Sets the auth cookie.static void
setAuthCookie
(String name, String value, int maxAge, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Sets the auth cookie.static void
setRawCookie
(String name, String value, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, boolean httpOnly, int maxAge) Sets a cookie.static void
setStateParam
(String name, String value, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Sets a cookie.static void
setStateParam
(String name, String value, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, boolean httpOnly) Sets a cookie.
-
Method Details
-
isAjaxRequest
public static boolean isAjaxRequest(jakarta.servlet.http.HttpServletRequest request) Checks if a request comes from JavaScript.- Parameters:
request
- HTTP request- Returns:
- true if AJAX
-
setStateParam
-
setStateParam
-
getStateParam
-
removeStateParam
public static void removeStateParam(String name, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Deletes a cookie.- Parameters:
name
- the namereq
- HTTP requestres
- HTTP response
-
setRawCookie
public static void setRawCookie(String name, String value, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res, boolean httpOnly, int maxAge) Sets a cookie.- Parameters:
name
- the namevalue
- the valuereq
- HTTP requestres
- HTTP responsehttpOnly
- HTTP only flagmaxAge
- max age
-
getCookieValue
-
setAuthCookie
-
setAuthCookie
public static void setAuthCookie(String name, String value, boolean httpOnly, int maxAge, String sameSite, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Sets the auth cookie.- Parameters:
name
- namevalue
- valuehttpOnly
- HTTP only flagmaxAge
- cookie validity in secondssameSite
- SameSite valuerequest
- requestresponse
- response
-