Moved attributes used only by strict specs when formatting cookies to SetCookie interface

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@563548 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2007-08-07 16:42:09 +00:00
parent 6475dd23d8
commit b88791b45f
5 changed files with 29 additions and 31 deletions

View File

@ -123,23 +123,5 @@ public interface Cookie {
*/
boolean isExpired(final Date date);
/**
* Returns <tt>true</tt> if cookie's path was set via a path attribute
* in the <tt>Set-Cookie</tt> header.
*
* @return value <tt>true</tt> if the cookie's path was explicitly
* set, <tt>false</tt> otherwise.
*/
boolean isPathAttributeSpecified();
/**
* Returns <tt>true</tt> if cookie's domain was set via a domain
* attribute in the <tt>Set-Cookie</tt> header.
*
* @return value <tt>true</tt> if the cookie's domain was explicitly
* set, <tt>false</tt> otherwise.
*/
boolean isDomainAttributeSpecified();
}

View File

@ -109,6 +109,15 @@ public interface SetCookie extends Cookie {
*/
void setVersion(int version);
/**
* Returns <tt>true</tt> if cookie's path was set via a path attribute
* in the <tt>Set-Cookie</tt> header.
*
* @return value <tt>true</tt> if the cookie's path was explicitly
* set, <tt>false</tt> otherwise.
*/
boolean isPathAttributeSpecified();
/**
* Indicates whether the cookie had a path specified in a
* path attribute of the <tt>Set-Cookie</tt> header. This value
@ -124,6 +133,15 @@ public interface SetCookie extends Cookie {
*/
public void setPathAttributeSpecified(boolean value);
/**
* Returns <tt>true</tt> if cookie's domain was set via a domain
* attribute in the <tt>Set-Cookie</tt> header.
*
* @return value <tt>true</tt> if the cookie's domain was explicitly
* set, <tt>false</tt> otherwise.
*/
boolean isDomainAttributeSpecified();
/**
* Indicates whether the cookie had a domain specified in a
* domain attribute of the <tt>Set-Cookie</tt> header. This value

View File

@ -30,15 +30,9 @@
package org.apache.http.impl.conn.tsccm;
import java.util.Iterator;
import java.util.LinkedList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.http.conn.HttpRoute;
//@@@ create entry w/o operator, set operator afterwards
import org.apache.http.conn.ClientConnectionOperator; //@@@
/**
* A connection sub-pool for a specific route, used by {@link ConnPoolByRoute}.

View File

@ -41,7 +41,6 @@
import org.apache.http.conn.ManagedClientConnection;
import org.apache.http.conn.OperatedClientConnection;
import org.apache.http.conn.SchemeRegistry;
import org.apache.http.conn.params.HttpConnectionManagerParams;
import org.apache.http.params.HttpParams;
import org.apache.http.impl.conn.DefaultClientConnectionOperator;

View File

@ -40,6 +40,7 @@
import org.apache.http.cookie.CookiePathComparator;
import org.apache.http.cookie.MalformedCookieException;
import org.apache.http.cookie.SM;
import org.apache.http.cookie.SetCookie;
import org.apache.http.message.BufferedHeader;
import org.apache.http.util.CharArrayBuffer;
@ -208,13 +209,17 @@ private void formatParamAsVer(final CharArrayBuffer buffer,
private void formatCookieAsVer(final CharArrayBuffer buffer,
final Cookie cookie, int version) {
formatParamAsVer(buffer, cookie.getName(), cookie.getValue(), version);
if (cookie.getPath() != null && cookie.isPathAttributeSpecified()) {
buffer.append("; ");
formatParamAsVer(buffer, "$Path", cookie.getPath(), version);
if (cookie.getPath() != null) {
if (cookie instanceof SetCookie && ((SetCookie) cookie).isPathAttributeSpecified()) {
buffer.append("; ");
formatParamAsVer(buffer, "$Path", cookie.getPath(), version);
}
}
if (cookie.getDomain() != null && cookie.isDomainAttributeSpecified()) {
buffer.append("; ");
formatParamAsVer(buffer, "$Domain", cookie.getDomain(), version);
if (cookie.getDomain() != null) {
if (cookie instanceof SetCookie && ((SetCookie) cookie).isDomainAttributeSpecified()) {
buffer.append("; ");
formatParamAsVer(buffer, "$Domain", cookie.getDomain(), version);
}
}
}