vmassol 01/10/05 11:01:21
Modified: src/framework/share/org/apache/cactus WebResponse.java
src/framework/share/org/apache/cactus/client
HttpClientHelper.java
Log:
moved to HttpClient 2.0 (the version in the main trunk of commons httpclient CVS)
Revision Changes Path
1.10 +7 -3
jakarta-cactus/src/framework/share/org/apache/cactus/WebResponse.java
Index: WebResponse.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/src/framework/share/org/apache/cactus/WebResponse.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- WebResponse.java 2001/09/16 11:11:58 1.9
+++ WebResponse.java 2001/10/05 18:01:21 1.10
@@ -72,7 +72,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: WebResponse.java,v 1.9 2001/09/16 11:11:58 vmassol Exp $
+ * @version $Id: WebResponse.java,v 1.10 2001/10/05 18:01:21 vmassol Exp $
*/
public class WebResponse
{
@@ -254,8 +254,12 @@
try {
cookies = org.apache.commons.httpclient.Cookie.parse(
HttpClientHelper.getDomain(getWebRequest(),
- getConnection()), new Header(headerName,
- headerValue));
+ getConnection()),
+ HttpClientHelper.getPort(getWebRequest(),
+ getConnection()),
+ HttpClientHelper.getPath(getWebRequest(),
+ getConnection()),
+ new Header(headerName, headerValue));
} catch (HttpException e) {
throw new ChainedRuntimeException(
"Error parsing cookies", e);
1.11 +44 -14
jakarta-cactus/src/framework/share/org/apache/cactus/client/HttpClientHelper.java
Index: HttpClientHelper.java
===================================================================
RCS file:
/home/cvs/jakarta-cactus/src/framework/share/org/apache/cactus/client/HttpClientHelper.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- HttpClientHelper.java 2001/09/14 20:15:26 1.10
+++ HttpClientHelper.java 2001/10/05 18:01:21 1.11
@@ -70,7 +70,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Vincent Massol</a>
*
- * @version $Id: HttpClientHelper.java,v 1.10 2001/09/14 20:15:26 pier Exp $
+ * @version $Id: HttpClientHelper.java,v 1.11 2001/10/05 18:01:21 vmassol Exp $
*/
public class HttpClientHelper
{
@@ -244,27 +244,27 @@
if (!cookies.isEmpty()) {
// transform the Cactus cookies into HttpClient cookies
- Vector httpclientCookies = new Vector();
- Enumeration enumCookies = cookies.elements();
- while (enumCookies.hasMoreElements()) {
+ org.apache.commons.httpclient.Cookie[] httpclientCookies =
+ new org.apache.commons.httpclient.Cookie[cookies.size()];
+ for (int i = 0; i < cookies.size(); i++) {
org.apache.cactus.Cookie cactusCookie =
- (org.apache.cactus.Cookie)enumCookies.nextElement();
- org.apache.commons.httpclient.Cookie httpclientCookie =
+ (org.apache.cactus.Cookie)cookies.elementAt(i);
+ httpclientCookies[i] =
new org.apache.commons.httpclient.Cookie(
cactusCookie.getDomain(), cactusCookie.getName(),
cactusCookie.getValue());
- httpclientCookie.setComment(cactusCookie.getComment());
- httpclientCookie.setExpiryDate(cactusCookie.getExpiryDate());
- httpclientCookie.setPath(cactusCookie.getPath());
- httpclientCookie.setSecure(cactusCookie.isSecure());
- httpclientCookies.addElement(httpclientCookie);
+ httpclientCookies[i].setComment(cactusCookie.getComment());
+ httpclientCookies[i].setExpiryDate(cactusCookie.getExpiryDate());
+ httpclientCookies[i].setPath(cactusCookie.getPath());
+ httpclientCookies[i].setSecure(cactusCookie.isSecure());
}
// and create the cookie header to send
Header cookieHeader =
org.apache.commons.httpclient.Cookie.createCookieHeader(
- getDomain(theRequest, theConnection),
- getPath(theRequest, theConnection), httpclientCookies);
+ HttpClientHelper.getDomain(theRequest, theConnection),
+ HttpClientHelper.getPath(theRequest, theConnection),
+ httpclientCookies);
logger.debug("Cookie string = [" + cookieHeader.getValue() +
"]");
@@ -307,6 +307,36 @@
}
/**
+ * Returns the domain that will be used to send the cookies. If a host
+ * was specified using <code>setURL()</code> then the domain will be
+ * this host. Otherwise it will be the redirector host.
+ *
+ * @param theRequest the request containing all data to pass to the server
+ * redirector.
+ * @param theConnection the HTTP connection
+ * @return the cookie domain to use
+ */
+ public static int getPort(WebRequest theRequest,
+ URLConnection theConnection)
+ {
+ logger.entry("getPort(...)");
+
+ int port;
+ ServletURL url = theRequest.getURL();
+
+ if ((url != null) && (url.getHost() != null)) {
+ port = url.getPort();
+ } else {
+ port = theConnection.getURL().getPort();
+ }
+
+ logger.debug("Cookie validation port = [" + port + "]");
+
+ logger.exit("getPort");
+ return port;
+ }
+
+ /**
* Returns the path that will be used to validate if a cookie will be
* sent or not. The algorithm is as follows : if the cookie path is not
* set (i.e. null) then the cookie is always sent (provided the domain
@@ -321,7 +351,7 @@
* @param theConnection the HTTP connection
* @return the path to use to decide if a cookie will get sent
*/
- private String getPath(WebRequest theRequest, URLConnection theConnection)
+ public static String getPath(WebRequest theRequest, URLConnection theConnection)
{
logger.entry("getPath(...)");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]