2009-02-26 08:59:37 +01:00
|
|
|
/*
|
2012-06-04 22:31:44 +02:00
|
|
|
* Copyright 2012 The Netty Project
|
2009-06-19 19:48:17 +02:00
|
|
|
*
|
2011-12-09 06:18:34 +01: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-26 08:59:37 +01:00
|
|
|
*
|
2012-06-04 22:31:44 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2009-02-26 08:59:37 +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
|
2011-12-09 06:18:34 +01:00
|
|
|
* 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-26 08:59:37 +01:00
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.handler.codec.http;
|
2009-02-26 08:59:37 +01:00
|
|
|
|
2009-03-13 13:32:47 +01:00
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
2009-02-26 08:59:37 +01:00
|
|
|
/**
|
2009-06-19 16:15:20 +02:00
|
|
|
* The default {@link Cookie} implementation.
|
2015-04-14 13:57:32 +02:00
|
|
|
*
|
|
|
|
* @deprecated Use {@link io.netty.handler.codec.http.cookie.DefaultCookie} instead.
|
2009-02-26 08:59:37 +01:00
|
|
|
*/
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
|
|
|
public class DefaultCookie extends io.netty.handler.codec.http.cookie.DefaultCookie implements Cookie {
|
2009-02-26 08:59:37 +01:00
|
|
|
|
|
|
|
private String comment;
|
2009-03-13 14:53:53 +01:00
|
|
|
private String commentUrl;
|
2009-03-13 11:12:51 +01:00
|
|
|
private boolean discard;
|
2009-03-13 13:32:47 +01:00
|
|
|
private Set<Integer> ports = Collections.emptySet();
|
|
|
|
private Set<Integer> unmodifiablePorts = ports;
|
2009-02-26 08:59:37 +01:00
|
|
|
private int version;
|
|
|
|
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* Creates a new cookie with the specified name and value.
|
|
|
|
*/
|
2009-02-26 08:59:37 +01:00
|
|
|
public DefaultCookie(String name, String value) {
|
2015-04-14 13:57:32 +02:00
|
|
|
super(name, value);
|
2009-02-26 08:59:37 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public String getName() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return name();
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public String getValue() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return value();
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public String getDomain() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return domain();
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public String getPath() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return path();
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public String getComment() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return comment();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2014-06-24 10:39:46 +02:00
|
|
|
public String comment() {
|
2009-02-26 08:59:37 +01:00
|
|
|
return comment;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public void setComment(String comment) {
|
2009-03-13 14:53:53 +01:00
|
|
|
this.comment = validateValue("comment", comment);
|
2009-02-26 08:59:37 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-03-13 14:53:53 +01:00
|
|
|
public String getCommentUrl() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return commentUrl();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2014-06-24 10:39:46 +02:00
|
|
|
public String commentUrl() {
|
2009-03-13 14:53:53 +01:00
|
|
|
return commentUrl;
|
2009-03-13 11:12:51 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2009-03-13 14:53:53 +01:00
|
|
|
public void setCommentUrl(String commentUrl) {
|
|
|
|
this.commentUrl = validateValue("commentUrl", commentUrl);
|
2009-03-13 11:12:51 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2009-03-13 11:12:51 +01:00
|
|
|
public boolean isDiscard() {
|
|
|
|
return discard;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2009-03-13 11:12:51 +01:00
|
|
|
public void setDiscard(boolean discard) {
|
|
|
|
this.discard = discard;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-03-13 13:32:47 +01:00
|
|
|
public Set<Integer> getPorts() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return ports();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2014-06-24 10:39:46 +02:00
|
|
|
public Set<Integer> ports() {
|
2009-03-13 13:32:47 +01:00
|
|
|
if (unmodifiablePorts == null) {
|
|
|
|
unmodifiablePorts = Collections.unmodifiableSet(ports);
|
|
|
|
}
|
|
|
|
return unmodifiablePorts;
|
2009-03-13 11:12:51 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2009-03-13 13:32:47 +01:00
|
|
|
public void setPorts(int... ports) {
|
|
|
|
if (ports == null) {
|
|
|
|
throw new NullPointerException("ports");
|
|
|
|
}
|
|
|
|
|
|
|
|
int[] portsCopy = ports.clone();
|
|
|
|
if (portsCopy.length == 0) {
|
|
|
|
unmodifiablePorts = this.ports = Collections.emptySet();
|
|
|
|
} else {
|
|
|
|
Set<Integer> newPorts = new TreeSet<Integer>();
|
|
|
|
for (int p: portsCopy) {
|
|
|
|
if (p <= 0 || p > 65535) {
|
|
|
|
throw new IllegalArgumentException("port out of range: " + p);
|
|
|
|
}
|
|
|
|
newPorts.add(Integer.valueOf(p));
|
|
|
|
}
|
|
|
|
this.ports = newPorts;
|
|
|
|
unmodifiablePorts = null;
|
2009-03-13 12:51:19 +01:00
|
|
|
}
|
2009-03-13 13:32:47 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2009-03-13 13:32:47 +01:00
|
|
|
public void setPorts(Iterable<Integer> ports) {
|
|
|
|
Set<Integer> newPorts = new TreeSet<Integer>();
|
|
|
|
for (int p: ports) {
|
2009-03-13 12:51:19 +01:00
|
|
|
if (p <= 0 || p > 65535) {
|
|
|
|
throw new IllegalArgumentException("port out of range: " + p);
|
|
|
|
}
|
2009-03-13 13:32:47 +01:00
|
|
|
newPorts.add(Integer.valueOf(p));
|
|
|
|
}
|
|
|
|
if (newPorts.isEmpty()) {
|
|
|
|
unmodifiablePorts = this.ports = Collections.emptySet();
|
|
|
|
} else {
|
|
|
|
this.ports = newPorts;
|
|
|
|
unmodifiablePorts = null;
|
2009-03-13 12:51:19 +01:00
|
|
|
}
|
2009-03-13 11:12:51 +01:00
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2012-06-08 02:25:39 +02:00
|
|
|
public long getMaxAge() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return maxAge();
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2014-06-24 10:39:46 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public int getVersion() {
|
2014-06-24 10:39:46 +02:00
|
|
|
return version();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2014-06-24 10:39:46 +02:00
|
|
|
public int version() {
|
2009-02-26 08:59:37 +01:00
|
|
|
return version;
|
|
|
|
}
|
|
|
|
|
2010-11-12 01:45:39 +01:00
|
|
|
@Override
|
2015-04-14 13:57:32 +02:00
|
|
|
@Deprecated
|
2009-02-26 08:59:37 +01:00
|
|
|
public void setVersion(int version) {
|
|
|
|
this.version = version;
|
|
|
|
}
|
2009-08-28 09:15:49 +02:00
|
|
|
}
|