summaryrefslogtreecommitdiffstats
path: root/src/java/net/sf
diff options
context:
space:
mode:
authormattinger <[email protected]>2006-08-22 19:02:17 +0000
committermattinger <[email protected]>2006-08-22 19:02:17 +0000
commit044594c1987203ed042805b34ea341df5f93a701 (patch)
tree3403696810b6020d7440f827d4a626595d9fe4fd /src/java/net/sf
parent21803b9c459f5b95b21766e3163593b654ef672c (diff)
git-svn-id: file:///home/sven/projects/JOGL/temp/ant-contrib/svn/ant-contrib-code/trunk/ant-contrib@36 32d7a393-a5a9-423c-abd3-5d954feb1f2f
Diffstat (limited to 'src/java/net/sf')
-rw-r--r--src/java/net/sf/antcontrib/net/httpclient/GetCookieTask.java43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/java/net/sf/antcontrib/net/httpclient/GetCookieTask.java b/src/java/net/sf/antcontrib/net/httpclient/GetCookieTask.java
index 4a2b3f9..2ae509e 100644
--- a/src/java/net/sf/antcontrib/net/httpclient/GetCookieTask.java
+++ b/src/java/net/sf/antcontrib/net/httpclient/GetCookieTask.java
@@ -64,6 +64,14 @@ public class GetCookieTask
this.property = property;
}
+ private Cookie findCookie(Cookie cookies[], String name) {
+ for (int i=0;i<cookies.length;i++) {
+ if (cookies[i].getName().equals(name)) {
+ return cookies[i];
+ }
+ }
+ return null;
+ }
protected void execute(HttpStateType stateType) throws BuildException {
if (realm == null || path == null) {
@@ -77,25 +85,40 @@ public class GetCookieTask
if (property != null) {
if (matches != null && matches.length > 0) {
- if (matches.length > 1) {
- log("Multiple cookies matched the query, returning only the first one.",
- Project.MSG_WARN);
+ Cookie toSet = matches[0];
+ if (name != null) {
+ toSet = findCookie(matches, name);
+ }
+
+ if (toSet != null) {
+ Property p = (Property)getProject().createTask("property");
+ p.setName(property);
+ p.setValue(matches[0].getValue());
+ p.perform();
}
- Property p = (Property)getProject().createTask("property");
- p.setName(property);
- p.setValue(matches[0].getValue());
- p.perform();
}
}
else if (prefix != null) {
if (matches != null && matches.length > 0) {
- for (int i=0;i<matches.length;i++) {
+ Cookie toSet[] = matches;
+
+ if (name != null) {
+ Cookie c = findCookie(matches, name);
+ if (c == null) {
+ toSet = new Cookie[0];
+ }
+ else {
+ toSet = new Cookie[] { c };
+ }
+ }
+
+ for (int i=0;i<toSet.length;i++) {
String propName =
prefix +
- matches[i].getName();
+ toSet[i].getName();
Property p = (Property)getProject().createTask("property");
p.setName(propName);
- p.setValue(matches[i].getValue());
+ p.setValue(toSet[i].getValue());
p.perform();
}
}