-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(citrus-http): review and code cleanup
pr: #1224 `citrus-http` module.
- Loading branch information
Showing
17 changed files
with
163 additions
and
158 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
endpoints/citrus-http/src/main/java/org/citrusframework/http/config/xml/CookieUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package org.citrusframework.http.config.xml; | ||
|
||
import jakarta.servlet.http.Cookie; | ||
import org.citrusframework.http.message.HttpMessage; | ||
import org.w3c.dom.Element; | ||
|
||
import java.util.List; | ||
|
||
import static java.lang.Boolean.parseBoolean; | ||
import static java.lang.Integer.parseInt; | ||
|
||
final class CookieUtils { | ||
|
||
private CookieUtils() { | ||
// Static utility class | ||
} | ||
|
||
static void setCookieElement(HttpMessage httpMessage, List<?> cookieElements) { | ||
for (Object item : cookieElements) { | ||
Element cookieElement = (Element) item; | ||
Cookie cookie = new Cookie(cookieElement.getAttribute("name"), cookieElement.getAttribute("value")); | ||
|
||
if (cookieElement.hasAttribute("path")) { | ||
cookie.setPath(cookieElement.getAttribute("path")); | ||
} | ||
|
||
if (cookieElement.hasAttribute("domain")) { | ||
cookie.setDomain(cookieElement.getAttribute("domain")); | ||
} | ||
|
||
if (cookieElement.hasAttribute("max-age")) { | ||
cookie.setMaxAge(parseInt(cookieElement.getAttribute("max-age"))); | ||
} | ||
|
||
if (cookieElement.hasAttribute("secure")) { | ||
cookie.setSecure(parseBoolean(cookieElement.getAttribute("secure"))); | ||
} | ||
|
||
httpMessage.cookie(cookie); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.