You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2004/03/15 21:26:49 UTC
cvs commit: jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http HttpClientConnectionHelper.java
vmassol 2004/03/15 12:26:49
Modified: framework/src/java/share/org/apache/cactus/util
CookieUtil.java
framework/src/test/share/org/apache/cactus/util
TestCookieUtil.java
framework/src/java/share/org/apache/cactus/client/connector/http
HttpClientConnectionHelper.java
Log:
refactoring: removed createHttpState() method which is not required. Also started creating an HttpState that can be passed to the authentication's configure() method in the upcoming refactoring.
Revision Changes Path
1.7 +1 -21 jakarta-cactus/framework/src/java/share/org/apache/cactus/util/CookieUtil.java
Index: CookieUtil.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/util/CookieUtil.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CookieUtil.java 29 Feb 2004 09:42:33 -0000 1.6
+++ CookieUtil.java 15 Mar 2004 20:26:49 -0000 1.7
@@ -27,7 +27,6 @@
import org.apache.cactus.WebRequest;
import org.apache.cactus.internal.client.ClientException;
import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.cookie.CookiePolicy;
import org.apache.commons.httpclient.cookie.CookieSpec;
import org.apache.commons.logging.Log;
@@ -314,24 +313,5 @@
}
return null;
- }
-
- /**
- * Create an HttpClient {@link HttpState} object containing all cookies
- * stored in the passed {@link WebRequest} object.
- *
- * @param theRequest the request containing the cookies to use when calling
- * the server side
- * @param theUrl the URL to connect to
- * @return an HttpClient {@link HttpState} object which has been set with
- * the cookies
- */
- public static HttpState createHttpState(WebRequest theRequest,
- URL theUrl)
- {
- HttpState state = new HttpState();
- state.addCookies(CookieUtil.createHttpClientCookies(theRequest,
- theUrl));
- return state;
}
}
1.6 +8 -5 jakarta-cactus/framework/src/test/share/org/apache/cactus/util/TestCookieUtil.java
Index: TestCookieUtil.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/test/share/org/apache/cactus/util/TestCookieUtil.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- TestCookieUtil.java 29 Feb 2004 09:37:35 -0000 1.5
+++ TestCookieUtil.java 15 Mar 2004 20:26:49 -0000 1.6
@@ -45,8 +45,9 @@
throws Exception
{
WebRequest request = new WebRequestImpl();
- HttpState state = CookieUtil.createHttpState(request,
- new URL("http://jakarta.apache.org"));
+ HttpState state = new HttpState();
+ state.addCookies(CookieUtil.createHttpClientCookies(request,
+ new URL("http://jakarta.apache.org")));
assertEquals(0, state.getCookies().length);
}
@@ -63,8 +64,10 @@
request.addCookie(new Cookie("domain1", "name1", "value1"));
request.addCookie(new Cookie("domain2", "name2", "value2"));
- HttpState state = CookieUtil.createHttpState(request,
- new URL("http://jakarta.apache.org"));
+ HttpState state = new HttpState();
+ state.addCookies(CookieUtil.createHttpClientCookies(request,
+ new URL("http://jakarta.apache.org")));
+
assertEquals(2, state.getCookies().length);
}
1.12 +6 -3 jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/HttpClientConnectionHelper.java
Index: HttpClientConnectionHelper.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/framework/src/java/share/org/apache/cactus/client/connector/http/HttpClientConnectionHelper.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- HttpClientConnectionHelper.java 29 Feb 2004 09:42:32 -0000 1.11
+++ HttpClientConnectionHelper.java 15 Mar 2004 20:26:49 -0000 1.12
@@ -77,6 +77,8 @@
{
URL url = new URL(this.url);
+ HttpState state = new HttpState();
+
// Add Authentication headers, if necessary. This is the first
// step to allow authentication to add extra headers, HTTP parameters,
// etc.
@@ -126,8 +128,9 @@
addHttpPostParameters(theRequest);
}
- // Add the cookies
- HttpState state = CookieUtil.createHttpState(theRequest, url);
+ // Add the cookies to the state
+ state.addCookies(CookieUtil.createHttpClientCookies(theRequest,
+ url));
// Open the connection and get the result
HttpClient client = new HttpClient();
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org