netty5/codec-http/src/main/java/io/netty/handler/codec/http/Cookie.java

209 lines
5.8 KiB
Java
Raw Normal View History

2009-02-17 18:13:13 +01:00
/*
2012-06-04 22:31:44 +02:00
* Copyright 2012 The Netty Project
2009-06-19 19:48:17 +02:00
*
* The Netty Project 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:
2009-02-17 18:13:13 +01:00
*
2012-06-04 22:31:44 +02:00
* http://www.apache.org/licenses/LICENSE-2.0
2009-02-17 18:13:13 +01:00
*
2009-08-28 09:15:49 +02:00
* 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
2009-08-28 09:15:49 +02:00
* License for the specific language governing permissions and limitations
* under the License.
2009-02-17 18:13:13 +01:00
*/
2011-12-09 04:38:59 +01:00
package io.netty.handler.codec.http;
2009-02-17 18:13:13 +01:00
import java.util.Set;
2009-02-17 18:13:13 +01:00
/**
2012-06-29 10:59:12 +02:00
* An interface defining an
* <a href="http://en.wikipedia.org/wiki/HTTP_cookie">HTTP cookie</a>.
2009-02-17 18:13:13 +01:00
*/
public interface Cookie extends Comparable<Cookie> {
2009-06-19 16:49:26 +02:00
/**
* Returns the name of this {@link Cookie}.
2012-06-29 10:59:12 +02:00
*
* @return The name of this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
String getName();
2009-06-19 16:49:26 +02:00
/**
* Returns the value of this {@link Cookie}.
2012-06-29 10:59:12 +02:00
*
* @return The value of this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
String getValue();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the value of this {@link Cookie}.
*
* @param value The value to set
2009-06-19 16:49:26 +02:00
*/
void setValue(String value);
2009-06-19 16:49:26 +02:00
/**
* Returns the domain of this {@link Cookie}.
2012-06-29 10:59:12 +02:00
*
* @return The domain of this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
String getDomain();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the domain of this {@link Cookie}.
*
* @param domain The domain to use
2009-06-19 16:49:26 +02:00
*/
void setDomain(String domain);
2009-06-19 16:49:26 +02:00
/**
* Returns the path of this {@link Cookie}.
2012-06-29 10:59:12 +02:00
*
* @return The {@link Cookie}'s path
2009-06-19 16:49:26 +02:00
*/
String getPath();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the path of this {@link Cookie}.
*
* @param path The path to use for this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
void setPath(String path);
2009-06-19 16:49:26 +02:00
/**
* Returns the comment of this {@link Cookie}.
2012-06-29 10:59:12 +02:00
*
* @return The comment of this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
String getComment();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the comment of this {@link Cookie}.
*
* @param comment The comment to use
2009-06-19 16:49:26 +02:00
*/
void setComment(String comment);
2009-06-19 16:49:26 +02:00
/**
* Returns the maximum age of this {@link Cookie} in seconds or {@link Long#MIN_VALUE} if unspecified
2012-06-29 10:59:12 +02:00
*
* @return The maximum age of this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
long getMaxAge();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the maximum age of this {@link Cookie} in seconds.
* If an age of {@code 0} is specified, this {@link Cookie} will be
* automatically removed by browser because it will expire immediately.
* If {@link Long#MIN_VALUE} is specified, this {@link Cookie} will be removed when the
2012-06-29 10:59:12 +02:00
* browser is closed.
*
* @param maxAge The maximum age of this {@link Cookie} in seconds
2009-06-19 16:49:26 +02:00
*/
void setMaxAge(long maxAge);
2009-06-19 16:49:26 +02:00
/**
* Returns the version of this {@link Cookie}.
2012-06-29 10:59:12 +02:00
*
* @return The version of this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
int getVersion();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the version of this {@link Cookie}.
*
* @param version The new version to use
2009-06-19 16:49:26 +02:00
*/
void setVersion(int version);
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Checks to see if this {@link Cookie} is secure
*
* @return True if this {@link Cookie} is secure, otherwise false
2009-06-19 16:49:26 +02:00
*/
boolean isSecure();
2009-06-19 16:49:26 +02:00
/**
* Sets the security getStatus of this {@link Cookie}
2012-06-29 10:59:12 +02:00
*
* @param secure True if this {@link Cookie} is to be secure, otherwise false
2009-06-19 16:49:26 +02:00
*/
void setSecure(boolean secure);
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Checks to see if this {@link Cookie} can only be accessed via HTTP.
* If this returns true, the {@link Cookie} cannot be accessed through
* client side script - But only if the browser supports it.
* For more information, please look <a href="http://www.owasp.org/index.php/HTTPOnly">here</a>
*
* @return True if this {@link Cookie} is HTTP-only or false if it isn't
*/
boolean isHttpOnly();
/**
2012-06-29 10:59:12 +02:00
* Determines if this {@link Cookie} is HTTP only.
* If set to true, this {@link Cookie} cannot be accessed by a client
* side script. However, this works only if the browser supports it.
* For for information, please look
* <a href="http://www.owasp.org/index.php/HTTPOnly">here</a>.
*
* @param httpOnly True if the {@link Cookie} is HTTP only, otherwise false.
*/
void setHttpOnly(boolean httpOnly);
2009-06-19 16:49:26 +02:00
/**
* Returns the comment URL of this {@link Cookie}.
2012-06-29 10:59:12 +02:00
*
* @return The comment URL of this {@link Cookie}
2009-06-19 16:49:26 +02:00
*/
String getCommentUrl();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the comment URL of this {@link Cookie}.
*
* @param commentUrl The comment URL to use
2009-06-19 16:49:26 +02:00
*/
void setCommentUrl(String commentUrl);
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Checks to see if this {@link Cookie} is to be discarded by the browser
* at the end of the current session.
*
* @return True if this {@link Cookie} is to be discarded, otherwise false
2009-06-19 16:49:26 +02:00
*/
boolean isDiscard();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the discard flag of this {@link Cookie}.
* If set to true, this {@link Cookie} will be discarded by the browser
* at the end of the current session
*
* @param discard True if the {@link Cookie} is to be discarded
2009-06-19 16:49:26 +02:00
*/
void setDiscard(boolean discard);
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Returns the ports that this {@link Cookie} can be accessed on.
*
* @return The {@link Set} of ports that this {@link Cookie} can use
2009-06-19 16:49:26 +02:00
*/
Set<Integer> getPorts();
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the ports that this {@link Cookie} can be accessed on.
*
* @param ports The ports that this {@link Cookie} can be accessed on
2009-06-19 16:49:26 +02:00
*/
void setPorts(int... ports);
2009-06-19 16:49:26 +02:00
/**
2012-06-29 10:59:12 +02:00
* Sets the ports that this {@link Cookie} can be accessed on.
*
* @param ports The {@link Iterable} collection of ports that this
* {@link Cookie} can be accessed on.
2009-06-19 16:49:26 +02:00
*/
void setPorts(Iterable<Integer> ports);
2009-08-28 09:15:49 +02:00
}