mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
utils: add findCookie value by key helping method in HttpUtils
finds cookie value from an array of cookie by key name Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> (cherry picked from commit 78ea36d099371b9a59cbf1e3efd48b853ecc37ca) Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
parent
0c8c089177
commit
7ae9f87d59
@ -21,6 +21,7 @@ package com.cloud.utils;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@ -49,6 +50,15 @@ public class HttpUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static String findCookie(final Cookie[] cookies, final String key) {
|
||||
for (Cookie cookie: cookies) {
|
||||
if (cookie != null && cookie.getName().equals(key)) {
|
||||
return cookie.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void writeHttpResponse(final HttpServletResponse resp, final String response,
|
||||
final Integer responseCode, final String responseType, final String jsonContentType) {
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user