* Added Port and commentURL attributes to Cookie interface (required by RFC2965)

* Added SetCookie2 interface representing the Set-Cookie2 header
* Copied CookieVersionSupport interface from HttpClient 3.1 branch 

git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@578403 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Oleg Kalnichevski 2007-09-22 10:56:04 +00:00
parent 8f3f51e39d
commit d8d769db59
9 changed files with 142 additions and 11 deletions

View File

@ -31,10 +31,6 @@
package org.apache.http.auth.params;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
/**
* Parameter names for HttpAuth.
*

View File

@ -30,8 +30,6 @@
package org.apache.http.conn.params;
import org.apache.http.params.HttpParams;
/**
* Parameter names for routing in HttpConn.
*

View File

@ -55,6 +55,11 @@ public interface ClientCookie extends Cookie {
public static final String COMMENT_ATTR = "comment";
public static final String EXPIRES_ATTR = "expires";
// RFC2965 attributes
public static final String PORT_ATTR = "port";
public static final String COMMENTURL_ATTR = "commenturl";
public static final String DISCARD_ATTR = "discard";
String getAttribute(String name);
boolean containsAttribute(String name);

View File

@ -66,6 +66,12 @@ public interface Cookie {
*/
String getComment();
/**
* If a user agent (web browser) presents this cookie to a user, the
* cookie's purpose will be described by the information at this URL.
*/
String getCommentURL();
/**
* Returns the expiration {@link Date} of the cookie, or <tt>null</tt>
* if none exists.
@ -99,6 +105,12 @@ public interface Cookie {
*/
String getPath();
/**
* Get the Port attribute. It restricts the ports to which a cookie
* may be returned in a Cookie request header.
*/
int[] getPorts();
/**
* Indicates whether this cookie requires a secure connection.
*

View File

@ -0,0 +1,48 @@
/*
* $HeadURL$
* $Revision$
* $Date$
*
* ====================================================================
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.cookie;
import org.apache.http.Header;
/**
* Defines cookie specification specific capabilities
*
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
*
* @since 3.1
*/
public interface CookieVersionSupport {
int getVersion();
Header getVersionHeader();
}

View File

@ -40,8 +40,8 @@ package org.apache.http.cookie;
*/
public interface SM {
public static final String COOKIE= "Cookie";
public static final String COOKIE = "Cookie";
public static final String COOKIE_2 = "Cookie2";
public static final String SET_COOKIE = "Set-Cookie";
}

View File

@ -0,0 +1,57 @@
/*
* $HeadURL$
* $Revision$
* $Date$
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/
package org.apache.http.cookie;
/**
* This interface represents a <code>SetCookie2</code> response header sent by the
* origin server to the HTTP agent in order to maintain a conversational state.
*
* @author <a href="mailto:oleg at ural.ru">Oleg Kalnichevski</a>
*
* @since 4.0
*/
public interface SetCookie2 extends Cookie {
/**
* If a user agent (web browser) presents this cookie to a user, the
* cookie's purpose will be described by the information at this URL.
*/
void setCommentURL(String commentURL);
/**
* Sets the Port attribute. It restricts the ports to which a cookie
* may be returned in a Cookie request header.
*/
void setPorts(int[] ports);
}

View File

@ -31,9 +31,6 @@
package org.apache.http.cookie.params;
import org.apache.http.params.HttpParams;
/**
* Parameter names for cookie specifications in HttpCookie.
*

View File

@ -126,6 +126,15 @@ public class BasicCookie implements SetCookie, ClientCookie {
cookieComment = comment;
}
/**
* Returns null. Cookies prior to RFC2965 do not set this attribute
*/
public String getCommentURL() {
return null;
}
/**
* Returns the expiration {@link Date} of the cookie, or <tt>null</tt>
* if none exists.
@ -243,6 +252,15 @@ public class BasicCookie implements SetCookie, ClientCookie {
isSecure = secure;
}
/**
* Returns null. Cookies prior to RFC2965 do not set this attribute
*/
public int[] getPorts() {
return null;
}
/**
* Returns the version of the cookie specification to which this
* cookie conforms.