Skip to content

Commit 7ae9f87

Browse files
committed
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>
1 parent 0c8c089 commit 7ae9f87

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎utils/src/com/cloud/utils/HttpUtils.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import org.apache.log4j.Logger;
2323

24+
import javax.servlet.http.Cookie;
2425
import javax.servlet.http.HttpServletResponse;
2526
import java.io.IOException;
2627

@@ -49,6 +50,15 @@ public static void addSecurityHeaders(final HttpServletResponse resp) {
4950
}
5051
}
5152

53+
public static String findCookie(final Cookie[] cookies, final String key) {
54+
for (Cookie cookie: cookies) {
55+
if (cookie != null && cookie.getName().equals(key)) {
56+
return cookie.getValue();
57+
}
58+
}
59+
return null;
60+
}
61+
5262
public static void writeHttpResponse(final HttpServletResponse resp, final String response,
5363
final Integer responseCode, final String responseType, final String jsonContentType) {
5464
try {

0 commit comments

Comments
 (0)