2008-11-19 08:22:15 +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:
|
2008-11-19 08:22:15 +01:00
|
|
|
*
|
2012-06-04 22:31:44 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2008-11-19 08:22:15 +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.
|
2008-11-19 08:22:15 +01:00
|
|
|
*/
|
2011-12-09 04:38:59 +01:00
|
|
|
package io.netty.handler.codec.http;
|
2008-11-19 08:22:15 +01:00
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
import io.netty.buffer.ByteBuf;
|
2015-04-01 01:23:52 +02:00
|
|
|
import io.netty.buffer.ByteBufUtil;
|
2015-01-20 01:48:11 +01:00
|
|
|
import io.netty.handler.codec.Headers.EntryVisitor;
|
2015-04-01 01:23:52 +02:00
|
|
|
import io.netty.util.AsciiString;
|
2015-01-20 01:48:11 +01:00
|
|
|
import io.netty.util.internal.PlatformDependent;
|
2013-11-28 08:15:14 +01:00
|
|
|
|
2011-05-11 10:02:11 +02:00
|
|
|
import java.text.ParseException;
|
2011-05-11 11:09:49 +02:00
|
|
|
import java.util.Calendar;
|
2013-01-16 05:22:50 +01:00
|
|
|
import java.util.Collections;
|
2011-05-11 10:02:11 +02:00
|
|
|
import java.util.Date;
|
2013-01-16 05:22:50 +01:00
|
|
|
import java.util.Iterator;
|
2010-01-08 09:29:37 +01:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2013-01-16 05:22:50 +01:00
|
|
|
import java.util.Map.Entry;
|
2010-01-08 09:29:37 +01:00
|
|
|
import java.util.Set;
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
import static io.netty.handler.codec.http.HttpConstants.*;
|
2015-01-20 01:48:11 +01:00
|
|
|
import static io.netty.util.internal.ObjectUtil.checkNotNull;
|
2014-10-31 08:48:28 +01:00
|
|
|
|
2008-11-19 08:22:15 +01:00
|
|
|
/**
|
2010-01-26 07:30:12 +01:00
|
|
|
* Provides the constants for the standard HTTP header names and values and
|
2013-01-16 05:22:50 +01:00
|
|
|
* commonly used utility methods that accesses an {@link HttpMessage}.
|
2008-11-19 08:22:15 +01:00
|
|
|
*/
|
2013-01-16 05:22:50 +01:00
|
|
|
public abstract class HttpHeaders implements Iterable<Map.Entry<String, String>> {
|
|
|
|
|
2014-06-04 11:34:57 +02:00
|
|
|
private static final byte[] HEADER_SEPERATOR = { COLON, SP };
|
2013-11-28 08:15:14 +01:00
|
|
|
private static final byte[] CRLF = { CR, LF };
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
public static final HttpHeaders EMPTY_HEADERS = new HttpHeaders() {
|
|
|
|
@Override
|
|
|
|
public String get(String name) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
@Override
|
|
|
|
public Integer getInt(CharSequence name) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getInt(CharSequence name, int defaultValue) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
@Override
|
|
|
|
public Short getShort(CharSequence name) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public short getShort(CharSequence name, short defaultValue) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
@Override
|
2014-10-31 19:08:59 +01:00
|
|
|
public Long getTimeMillis(CharSequence name) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-10-31 19:08:59 +01:00
|
|
|
public long getTimeMillis(CharSequence name, long defaultValue) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
@Override
|
|
|
|
public List<String> getAll(String name) {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<Entry<String, String>> entries() {
|
|
|
|
return Collections.emptyList();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean contains(String name) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isEmpty() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Set<String> names() {
|
|
|
|
return Collections.emptySet();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-01-16 15:56:51 +01:00
|
|
|
public HttpHeaders add(String name, Object value) {
|
2013-01-16 05:22:50 +01:00
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-01-16 15:56:51 +01:00
|
|
|
public HttpHeaders add(String name, Iterable<?> values) {
|
2013-01-16 05:22:50 +01:00
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
@Override
|
|
|
|
public HttpHeaders addInt(CharSequence name, int value) {
|
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
@Override
|
|
|
|
public HttpHeaders addShort(CharSequence name, short value) {
|
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
@Override
|
2013-01-16 15:56:51 +01:00
|
|
|
public HttpHeaders set(String name, Object value) {
|
2013-01-16 05:22:50 +01:00
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-01-16 15:56:51 +01:00
|
|
|
public HttpHeaders set(String name, Iterable<?> values) {
|
2013-01-16 05:22:50 +01:00
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
@Override
|
|
|
|
public HttpHeaders setInt(CharSequence name, int value) {
|
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
@Override
|
|
|
|
public HttpHeaders setShort(CharSequence name, short value) {
|
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
@Override
|
2013-01-16 15:56:51 +01:00
|
|
|
public HttpHeaders remove(String name) {
|
2013-01-16 05:22:50 +01:00
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-01-16 15:56:51 +01:00
|
|
|
public HttpHeaders clear() {
|
2013-01-16 05:22:50 +01:00
|
|
|
throw new UnsupportedOperationException("read only");
|
|
|
|
}
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
@Override
|
|
|
|
public Entry<CharSequence, CharSequence> forEachEntry(EntryVisitor<CharSequence> visitor) throws Exception {
|
|
|
|
return null; // Since this is an empty header collection
|
|
|
|
}
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
@Override
|
|
|
|
public Iterator<Entry<String, String>> iterator() {
|
|
|
|
return entries().iterator();
|
|
|
|
}
|
|
|
|
};
|
2009-06-19 16:15:20 +02:00
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderNames} instead.
|
|
|
|
*
|
2013-02-14 21:09:16 +01:00
|
|
|
* Standard HTTP header names.
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2010-01-26 09:10:34 +01:00
|
|
|
public static final class Names {
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Accept"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCEPT = "Accept";
|
2009-12-16 08:23:35 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Accept-Charset"}
|
2009-12-16 08:23:35 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCEPT_CHARSET = "Accept-Charset";
|
2012-09-27 12:16:02 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Accept-Encoding"}
|
2012-09-27 12:16:02 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCEPT_ENCODING = "Accept-Encoding";
|
2012-09-27 12:16:02 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Accept-Language"}
|
2012-09-27 12:16:02 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCEPT_LANGUAGE = "Accept-Language";
|
2012-09-27 12:16:02 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Accept-Ranges"}
|
2012-09-27 12:16:02 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCEPT_RANGES = "Accept-Ranges";
|
2012-09-27 12:16:02 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Accept-Patch"}
|
2012-09-27 12:16:02 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCEPT_PATCH = "Accept-Patch";
|
2012-09-28 12:18:21 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Allow-Credentials"}
|
2012-09-28 12:18:21 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_ALLOW_CREDENTIALS = "Access-Control-Allow-Credentials";
|
2012-09-27 12:16:02 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Allow-Headers"}
|
2012-09-27 12:16:02 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_ALLOW_HEADERS = "Access-Control-Allow-Headers";
|
2012-09-27 12:16:02 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Allow-Methods"}
|
2012-09-27 12:16:02 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_ALLOW_METHODS = "Access-Control-Allow-Methods";
|
2012-09-27 12:16:02 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Allow-Origin"}
|
2012-09-27 12:16:02 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_ALLOW_ORIGIN = "Access-Control-Allow-Origin";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Expose-Headers"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_EXPOSE_HEADERS = "Access-Control-Expose-Headers";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Max-Age"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_MAX_AGE = "Access-Control-Max-Age";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Request-Headers"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_REQUEST_HEADERS = "Access-Control-Request-Headers";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Access-Control-Request-Method"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ACCESS_CONTROL_REQUEST_METHOD = "Access-Control-Request-Method";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Age"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String AGE = "Age";
|
2010-01-26 09:16:58 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Allow"}
|
2010-01-26 09:16:58 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ALLOW = "Allow";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Authorization"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String AUTHORIZATION = "Authorization";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Cache-Control"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CACHE_CONTROL = "Cache-Control";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Connection"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONNECTION = "Connection";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Base"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_BASE = "Content-Base";
|
2009-06-30 11:29:35 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Encoding"}
|
2009-06-30 11:29:35 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_ENCODING = "Content-Encoding";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Language"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_LANGUAGE = "Content-Language";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Length"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_LENGTH = "Content-Length";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Location"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_LOCATION = "Content-Location";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Transfer-Encoding"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-MD5"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_MD5 = "Content-MD5";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Range"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_RANGE = "Content-Range";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Content-Type"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String CONTENT_TYPE = "Content-Type";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Cookie"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String COOKIE = "Cookie";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Date"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String DATE = "Date";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "ETag"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ETAG = "ETag";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Expect"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String EXPECT = "Expect";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Expires"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String EXPIRES = "Expires";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "From"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String FROM = "From";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Host"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String HOST = "Host";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "If-Match"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String IF_MATCH = "If-Match";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "If-Modified-Since"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "If-None-Match"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String IF_NONE_MATCH = "If-None-Match";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "If-Range"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String IF_RANGE = "If-Range";
|
2010-01-07 08:57:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "If-Unmodified-Since"}
|
2010-01-07 08:57:14 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Last-Modified"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String LAST_MODIFIED = "Last-Modified";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Location"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String LOCATION = "Location";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Max-Forwards"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String MAX_FORWARDS = "Max-Forwards";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Origin"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String ORIGIN = "Origin";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Pragma"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String PRAGMA = "Pragma";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Proxy-Authenticate"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
|
2010-06-21 11:39:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Proxy-Authorization"}
|
2010-06-21 11:39:49 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
|
2010-06-21 11:39:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Range"}
|
2010-06-21 11:39:49 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String RANGE = "Range";
|
2010-06-21 11:39:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Referer"}
|
2010-06-21 11:39:49 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String REFERER = "Referer";
|
2010-06-21 11:39:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Retry-After"}
|
2010-06-21 11:39:49 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String RETRY_AFTER = "Retry-After";
|
2010-06-21 11:39:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Key1"}
|
2010-06-21 11:39:49 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_KEY1 = "Sec-WebSocket-Key1";
|
2011-09-26 14:51:15 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Key2"}
|
2011-09-26 14:51:15 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_KEY2 = "Sec-WebSocket-Key2";
|
2011-09-26 14:51:15 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Location"}
|
2011-09-26 14:51:15 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_LOCATION = "Sec-WebSocket-Location";
|
2011-09-26 14:51:15 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Origin"}
|
2011-09-26 14:51:15 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_ORIGIN = "Sec-WebSocket-Origin";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Protocol"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_PROTOCOL = "Sec-WebSocket-Protocol";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Version"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_VERSION = "Sec-WebSocket-Version";
|
2009-06-30 11:42:34 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Key"}
|
2009-06-30 11:42:34 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_KEY = "Sec-WebSocket-Key";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Sec-WebSocket-Accept"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SEC_WEBSOCKET_ACCEPT = "Sec-WebSocket-Accept";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Server"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SERVER = "Server";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Set-Cookie"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SET_COOKIE = "Set-Cookie";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Set-Cookie2"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String SET_COOKIE2 = "Set-Cookie2";
|
2014-09-19 01:04:35 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "TE"}
|
2014-09-19 01:04:35 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String TE = "TE";
|
2014-09-19 01:04:35 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Trailer"}
|
2014-09-19 01:04:35 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String TRAILER = "Trailer";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Transfer-Encoding"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String TRANSFER_ENCODING = "Transfer-Encoding";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Upgrade"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String UPGRADE = "Upgrade";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "User-Agent"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String USER_AGENT = "User-Agent";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Vary"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String VARY = "Vary";
|
2010-01-07 08:57:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Via"}
|
2010-01-07 08:57:14 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String VIA = "Via";
|
2010-01-07 08:57:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "Warning"}
|
2010-01-07 08:57:14 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String WARNING = "Warning";
|
2010-01-07 08:57:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "WebSocket-Location"}
|
2010-01-07 08:57:14 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String WEBSOCKET_LOCATION = "WebSocket-Location";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "WebSocket-Origin"}
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String WEBSOCKET_ORIGIN = "WebSocket-Origin";
|
2014-09-19 01:04:35 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "WebSocket-Protocol"}
|
2014-09-19 01:04:35 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String WEBSOCKET_PROTOCOL = "WebSocket-Protocol";
|
2014-09-19 01:04:35 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* {@code "WWW-Authenticate"}
|
2014-09-19 01:04:35 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
|
2008-11-19 08:22:15 +01:00
|
|
|
|
2010-01-26 09:10:34 +01:00
|
|
|
private Names() {
|
2009-02-11 09:48:39 +01:00
|
|
|
}
|
|
|
|
}
|
2008-11-19 08:22:15 +01:00
|
|
|
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderValues} instead.
|
|
|
|
*
|
2009-06-19 16:17:02 +02:00
|
|
|
* Standard HTTP header values.
|
2009-06-19 16:15:20 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2010-01-26 09:10:34 +01:00
|
|
|
public static final class Values {
|
2010-11-12 01:45:39 +01:00
|
|
|
/**
|
|
|
|
* {@code "application/x-www-form-urlencoded"}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String APPLICATION_X_WWW_FORM_URLENCODED =
|
|
|
|
"application/x-www-form-urlencoded";
|
2009-06-30 11:29:35 +02:00
|
|
|
/**
|
|
|
|
* {@code "base64"}
|
|
|
|
*/
|
|
|
|
public static final String BASE64 = "base64";
|
|
|
|
/**
|
|
|
|
* {@code "binary"}
|
|
|
|
*/
|
|
|
|
public static final String BINARY = "binary";
|
2010-11-12 01:45:39 +01:00
|
|
|
/**
|
|
|
|
* {@code "boundary"}
|
|
|
|
*/
|
2012-05-31 20:32:42 +02:00
|
|
|
public static final String BOUNDARY = "boundary";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "bytes"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String BYTES = "bytes";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "charset"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String CHARSET = "charset";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "chunked"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String CHUNKED = "chunked";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "close"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String CLOSE = "close";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "compress"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String COMPRESS = "compress";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "100-continue"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String CONTINUE = "100-continue";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "deflate"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String DEFLATE = "deflate";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "gzip"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String GZIP = "gzip";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "identity"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String IDENTITY = "identity";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "keep-alive"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String KEEP_ALIVE = "keep-alive";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "max-age"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String MAX_AGE = "max-age";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "max-stale"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String MAX_STALE = "max-stale";
|
2010-01-25 05:22:45 +01:00
|
|
|
/**
|
|
|
|
* {@code "min-fresh"}
|
|
|
|
*/
|
|
|
|
public static final String MIN_FRESH = "min-fresh";
|
2010-11-12 01:45:39 +01:00
|
|
|
/**
|
|
|
|
* {@code "multipart/form-data"}
|
|
|
|
*/
|
2012-05-31 20:32:42 +02:00
|
|
|
public static final String MULTIPART_FORM_DATA = "multipart/form-data";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "must-revalidate"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String MUST_REVALIDATE = "must-revalidate";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "no-cache"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String NO_CACHE = "no-cache";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "no-store"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String NO_STORE = "no-store";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "no-transform"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String NO_TRANSFORM = "no-transform";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "none"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String NONE = "none";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "only-if-cached"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String ONLY_IF_CACHED = "only-if-cached";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "private"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String PRIVATE = "private";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "proxy-revalidate"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String PROXY_REVALIDATE = "proxy-revalidate";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "public"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String PUBLIC = "public";
|
2009-06-30 11:29:35 +02:00
|
|
|
/**
|
|
|
|
* {@code "quoted-printable"}
|
|
|
|
*/
|
|
|
|
public static final String QUOTED_PRINTABLE = "quoted-printable";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "s-maxage"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String S_MAXAGE = "s-maxage";
|
2009-06-19 16:15:20 +02:00
|
|
|
/**
|
|
|
|
* {@code "trailers"}
|
|
|
|
*/
|
2009-02-11 09:48:39 +01:00
|
|
|
public static final String TRAILERS = "trailers";
|
2010-01-08 09:29:37 +01:00
|
|
|
/**
|
|
|
|
* {@code "Upgrade"}
|
|
|
|
*/
|
|
|
|
public static final String UPGRADE = "Upgrade";
|
2010-01-07 08:57:14 +01:00
|
|
|
/**
|
|
|
|
* {@code "WebSocket"}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
public static final String WEBSOCKET = "WebSocket";
|
2008-11-19 08:22:15 +01:00
|
|
|
|
2010-01-26 09:10:34 +01:00
|
|
|
private Values() {
|
2009-02-11 09:48:39 +01:00
|
|
|
}
|
2008-11-19 08:22:15 +01:00
|
|
|
}
|
|
|
|
|
2010-01-27 03:38:17 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#isKeepAlive(HttpMessage)} instead.
|
|
|
|
*
|
2010-01-27 03:38:17 +01:00
|
|
|
* Returns {@code true} if and only if the connection can remain open and
|
|
|
|
* thus 'kept alive'. This methods respects the value of the
|
|
|
|
* {@code "Connection"} header first and then the return value of
|
|
|
|
* {@link HttpVersion#isKeepAliveDefault()}.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static boolean isKeepAlive(HttpMessage message) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return HttpHeaderUtil.isKeepAlive(message);
|
2010-01-27 03:38:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#setKeepAlive(HttpMessage, boolean)} instead.
|
|
|
|
*
|
2010-01-27 03:38:17 +01:00
|
|
|
* Sets the value of the {@code "Connection"} header depending on the
|
2013-01-30 07:42:18 +01:00
|
|
|
* protocol version of the specified message. This getMethod sets or removes
|
2010-01-27 03:38:17 +01:00
|
|
|
* the {@code "Connection"} header depending on what the default keep alive
|
|
|
|
* mode of the message's protocol version is, as specified by
|
|
|
|
* {@link HttpVersion#isKeepAliveDefault()}.
|
|
|
|
* <ul>
|
|
|
|
* <li>If the connection is kept alive by default:
|
|
|
|
* <ul>
|
|
|
|
* <li>set to {@code "close"} if {@code keepAlive} is {@code false}.</li>
|
|
|
|
* <li>remove otherwise.</li>
|
|
|
|
* </ul></li>
|
|
|
|
* <li>If the connection is closed by default:
|
|
|
|
* <ul>
|
|
|
|
* <li>set to {@code "keep-alive"} if {@code keepAlive} is {@code true}.</li>
|
|
|
|
* <li>remove otherwise.</li>
|
|
|
|
* </ul></li>
|
|
|
|
* </ul>
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void setKeepAlive(HttpMessage message, boolean keepAlive) {
|
2014-10-31 08:48:28 +01:00
|
|
|
HttpHeaderUtil.setKeepAlive(message, keepAlive);
|
2010-01-27 03:38:17 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #get(CharSequence)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #getHeader(HttpMessage, CharSequence)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static String getHeader(HttpMessage message, String name) {
|
|
|
|
return message.headers().get(name);
|
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #get(CharSequence)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Returns the header value with the specified header name. If there are
|
|
|
|
* more than one header value for the specified header name, the first
|
|
|
|
* value is returned.
|
|
|
|
*
|
|
|
|
* @return the header value or {@code null} if there is no such header
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static String getHeader(HttpMessage message, CharSequence name) {
|
2013-01-16 05:22:50 +01:00
|
|
|
return message.headers().get(name);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #get(CharSequence, String)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #getHeader(HttpMessage, CharSequence, String)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static String getHeader(HttpMessage message, String name, String defaultValue) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return message.headers().get(name, defaultValue);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #get(CharSequence, String)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Returns the header value with the specified header name. If there are
|
|
|
|
* more than one header value for the specified header name, the first
|
|
|
|
* value is returned.
|
|
|
|
*
|
|
|
|
* @return the header value or the {@code defaultValue} if there is no such
|
|
|
|
* header
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static String getHeader(HttpMessage message, CharSequence name, String defaultValue) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return message.headers().get(name, defaultValue);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Object)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #setHeader(HttpMessage, CharSequence, Object)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setHeader(HttpMessage message, String name, Object value) {
|
|
|
|
message.headers().set(name, value);
|
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Object)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Sets a new header with the specified name and value. If there is an
|
|
|
|
* existing header with the same name, the existing header is removed.
|
2011-05-11 11:09:49 +02:00
|
|
|
* If the specified value is not a {@link String}, it is converted into a
|
|
|
|
* {@link String} by {@link Object#toString()}, except for {@link Date}
|
|
|
|
* and {@link Calendar} which are formatted to the date format defined in
|
|
|
|
* <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>.
|
2010-05-06 09:50:19 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setHeader(HttpMessage message, CharSequence name, Object value) {
|
2013-01-16 05:22:50 +01:00
|
|
|
message.headers().set(name, value);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Iterable)} instead.
|
2013-11-28 08:15:14 +01:00
|
|
|
*
|
|
|
|
* @see {@link #setHeader(HttpMessage, CharSequence, Iterable)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setHeader(HttpMessage message, String name, Iterable<?> values) {
|
|
|
|
message.headers().set(name, values);
|
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Iterable)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Sets a new header with the specified name and values. If there is an
|
|
|
|
* existing header with the same name, the existing header is removed.
|
2013-01-30 07:42:18 +01:00
|
|
|
* This getMethod can be represented approximately as the following code:
|
2011-05-11 11:09:49 +02:00
|
|
|
* <pre>
|
|
|
|
* removeHeader(message, name);
|
|
|
|
* for (Object v: values) {
|
|
|
|
* if (v == null) {
|
|
|
|
* break;
|
|
|
|
* }
|
|
|
|
* addHeader(message, name, v);
|
|
|
|
* }
|
|
|
|
* </pre>
|
2010-05-06 09:50:19 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setHeader(HttpMessage message, CharSequence name, Iterable<?> values) {
|
2013-01-16 05:22:50 +01:00
|
|
|
message.headers().set(name, values);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #add(CharSequence, Object)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #addHeader(HttpMessage, CharSequence, Object)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void addHeader(HttpMessage message, String name, Object value) {
|
|
|
|
message.headers().add(name, value);
|
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #add(CharSequence, Object)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Adds a new header with the specified name and value.
|
2011-05-11 11:09:49 +02:00
|
|
|
* If the specified value is not a {@link String}, it is converted into a
|
|
|
|
* {@link String} by {@link Object#toString()}, except for {@link Date}
|
|
|
|
* and {@link Calendar} which are formatted to the date format defined in
|
|
|
|
* <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>.
|
2010-05-06 09:50:19 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void addHeader(HttpMessage message, CharSequence name, Object value) {
|
2013-01-16 05:22:50 +01:00
|
|
|
message.headers().add(name, value);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2011-05-11 11:09:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #remove(CharSequence)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #removeHeader(HttpMessage, CharSequence)}
|
2011-05-11 11:09:49 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void removeHeader(HttpMessage message, String name) {
|
|
|
|
message.headers().remove(name);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #remove(CharSequence)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* Removes the header with the specified name.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void removeHeader(HttpMessage message, CharSequence name) {
|
|
|
|
message.headers().remove(name);
|
|
|
|
}
|
|
|
|
|
2011-05-11 11:09:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #clear()} instead.
|
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Removes all headers from the specified message.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void clearHeaders(HttpMessage message) {
|
|
|
|
message.headers().clear();
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #getInt(CharSequence)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #getIntHeader(HttpMessage, CharSequence)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static int getIntHeader(HttpMessage message, String name) {
|
|
|
|
return getIntHeader(message, (CharSequence) name);
|
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #getInt(CharSequence)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Returns the integer header value with the specified header name. If
|
|
|
|
* there are more than one header value for the specified header name, the
|
|
|
|
* first value is returned.
|
|
|
|
*
|
|
|
|
* @return the header value
|
|
|
|
* @throws NumberFormatException
|
|
|
|
* if there is no such header or the header value is not a number
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static int getIntHeader(HttpMessage message, CharSequence name) {
|
2014-10-31 08:48:28 +01:00
|
|
|
String value = message.headers().get(name);
|
2010-05-06 09:50:19 +02:00
|
|
|
if (value == null) {
|
2011-05-11 11:09:49 +02:00
|
|
|
throw new NumberFormatException("header not found: " + name);
|
2010-05-06 09:50:19 +02:00
|
|
|
}
|
|
|
|
return Integer.parseInt(value);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #getInt(CharSequence, int)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #getIntHeader(HttpMessage, CharSequence, int)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static int getIntHeader(HttpMessage message, String name, int defaultValue) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return message.headers().getInt(name, defaultValue);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #getInt(CharSequence, int)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Returns the integer header value with the specified header name. If
|
|
|
|
* there are more than one header value for the specified header name, the
|
|
|
|
* first value is returned.
|
|
|
|
*
|
|
|
|
* @return the header value or the {@code defaultValue} if there is no such
|
|
|
|
* header or the header value is not a number
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static int getIntHeader(HttpMessage message, CharSequence name, int defaultValue) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return message.headers().getInt(name, defaultValue);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #setInt(CharSequence, int)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #setIntHeader(HttpMessage, CharSequence, int)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setIntHeader(HttpMessage message, String name, int value) {
|
2014-10-31 08:48:28 +01:00
|
|
|
message.headers().setInt(name, value);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #setInt(CharSequence, int)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Sets a new integer header with the specified name and value. If there
|
|
|
|
* is an existing header with the same name, the existing header is removed.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setIntHeader(HttpMessage message, CharSequence name, int value) {
|
2014-10-31 08:48:28 +01:00
|
|
|
message.headers().setInt(name, value);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Iterable)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #setIntHeader(HttpMessage, CharSequence, Iterable)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setIntHeader(HttpMessage message, String name, Iterable<Integer> values) {
|
|
|
|
message.headers().set(name, values);
|
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Iterable)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Sets a new integer header with the specified name and values. If there
|
|
|
|
* is an existing header with the same name, the existing header is removed.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setIntHeader(HttpMessage message, CharSequence name, Iterable<Integer> values) {
|
2013-01-16 05:22:50 +01:00
|
|
|
message.headers().set(name, values);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #add(CharSequence, Iterable)} instead.
|
2013-11-28 08:15:14 +01:00
|
|
|
*
|
|
|
|
* @see {@link #addIntHeader(HttpMessage, CharSequence, int)}
|
2010-05-06 09:50:19 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void addIntHeader(HttpMessage message, String name, int value) {
|
|
|
|
message.headers().add(name, value);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #addInt(CharSequence, int)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* Adds a new integer header with the specified name and value.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void addIntHeader(HttpMessage message, CharSequence name, int value) {
|
2014-10-31 08:48:28 +01:00
|
|
|
message.headers().addInt(name, value);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 19:08:59 +01:00
|
|
|
* @deprecated Use {@link #getTimeMillis(CharSequence)} instead.
|
2014-10-31 08:48:28 +01:00
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #getDateHeader(HttpMessage, CharSequence)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static Date getDateHeader(HttpMessage message, String name) throws ParseException {
|
|
|
|
return getDateHeader(message, (CharSequence) name);
|
|
|
|
}
|
|
|
|
|
2011-05-11 11:09:49 +02:00
|
|
|
/**
|
2014-10-31 19:08:59 +01:00
|
|
|
* @deprecated Use {@link #getTimeMillis(CharSequence)} instead.
|
2014-10-31 08:48:28 +01:00
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Returns the date header value with the specified header name. If
|
|
|
|
* there are more than one header value for the specified header name, the
|
|
|
|
* first value is returned.
|
|
|
|
*
|
|
|
|
* @return the header value
|
|
|
|
* @throws ParseException
|
|
|
|
* if there is no such header or the header value is not a formatted date
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static Date getDateHeader(HttpMessage message, CharSequence name) throws ParseException {
|
2014-10-31 08:48:28 +01:00
|
|
|
String value = message.headers().get(name);
|
2011-05-11 11:09:49 +02:00
|
|
|
if (value == null) {
|
|
|
|
throw new ParseException("header not found: " + name, 0);
|
|
|
|
}
|
2013-05-23 11:39:50 +02:00
|
|
|
return HttpHeaderDateFormat.get().parse(value);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 19:08:59 +01:00
|
|
|
* @deprecated Use {@link #getTimeMillis(CharSequence, long)} instead.
|
2014-10-31 08:48:28 +01:00
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #getDateHeader(HttpMessage, CharSequence, Date)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static Date getDateHeader(HttpMessage message, String name, Date defaultValue) {
|
2014-10-31 19:08:59 +01:00
|
|
|
return getDateHeader(message, (CharSequence) name, defaultValue);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
|
|
|
|
2011-05-11 11:09:49 +02:00
|
|
|
/**
|
2014-10-31 19:08:59 +01:00
|
|
|
* @deprecated Use {@link #getTimeMillis(CharSequence, long)} instead.
|
2014-10-31 08:48:28 +01:00
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Returns the date header value with the specified header name. If
|
|
|
|
* there are more than one header value for the specified header name, the
|
|
|
|
* first value is returned.
|
|
|
|
*
|
|
|
|
* @return the header value or the {@code defaultValue} if there is no such
|
|
|
|
* header or the header value is not a formatted date
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static Date getDateHeader(HttpMessage message, CharSequence name, Date defaultValue) {
|
2014-10-31 19:08:59 +01:00
|
|
|
final String value = getHeader(message, name);
|
|
|
|
if (value == null) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
return HttpHeaderDateFormat.get().parse(value);
|
|
|
|
} catch (ParseException ignored) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Object)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #setDateHeader(HttpMessage, CharSequence, Date)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setDateHeader(HttpMessage message, String name, Date value) {
|
|
|
|
setDateHeader(message, (CharSequence) name, value);
|
|
|
|
}
|
|
|
|
|
2011-05-11 11:09:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Object)} instead.
|
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Sets a new date header with the specified name and value. If there
|
|
|
|
* is an existing header with the same name, the existing header is removed.
|
|
|
|
* The specified value is formatted as defined in
|
|
|
|
* <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setDateHeader(HttpMessage message, CharSequence name, Date value) {
|
2011-05-11 11:09:49 +02:00
|
|
|
if (value != null) {
|
2013-05-23 11:39:50 +02:00
|
|
|
message.headers().set(name, HttpHeaderDateFormat.get().format(value));
|
2011-05-11 11:09:49 +02:00
|
|
|
} else {
|
2013-01-16 05:22:50 +01:00
|
|
|
message.headers().set(name, null);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Iterable)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #setDateHeader(HttpMessage, CharSequence, Iterable)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setDateHeader(HttpMessage message, String name, Iterable<Date> values) {
|
|
|
|
message.headers().set(name, values);
|
|
|
|
}
|
|
|
|
|
2011-05-11 11:09:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Iterable)} instead.
|
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Sets a new date header with the specified name and values. If there
|
|
|
|
* is an existing header with the same name, the existing header is removed.
|
|
|
|
* The specified values are formatted as defined in
|
|
|
|
* <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setDateHeader(HttpMessage message, CharSequence name, Iterable<Date> values) {
|
2013-01-16 05:22:50 +01:00
|
|
|
message.headers().set(name, values);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #add(CharSequence, Object)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #addDateHeader(HttpMessage, CharSequence, Date)}
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void addDateHeader(HttpMessage message, String name, Date value) {
|
|
|
|
message.headers().add(name, value);
|
|
|
|
}
|
|
|
|
|
2011-05-11 11:09:49 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #add(CharSequence, Object)} instead.
|
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Adds a new date header with the specified name and value. The specified
|
2012-06-08 12:28:12 +02:00
|
|
|
* value is formatted as defined in
|
|
|
|
* <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>
|
2011-05-11 11:09:49 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void addDateHeader(HttpMessage message, CharSequence name, Date value) {
|
2013-01-16 05:22:50 +01:00
|
|
|
message.headers().add(name, value);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
2010-02-18 05:08:56 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#getContentLength(HttpMessage)} instead.
|
|
|
|
*
|
2010-02-18 05:08:56 +01:00
|
|
|
* Returns the length of the content. Please note that this value is
|
2013-05-01 10:04:43 +02:00
|
|
|
* not retrieved from {@link HttpContent#content()} but from the
|
2010-02-18 05:08:56 +01:00
|
|
|
* {@code "Content-Length"} header, and thus they are independent from each
|
|
|
|
* other.
|
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* @return the content length
|
|
|
|
*
|
|
|
|
* @throws NumberFormatException
|
|
|
|
* if the message does not have the {@code "Content-Length"} header
|
|
|
|
* or its value is not a number
|
2010-02-18 05:08:56 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static long getContentLength(HttpMessage message) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return HttpHeaderUtil.getContentLength(message);
|
2010-02-18 05:08:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#getContentLength(HttpMessage, long)} instead.
|
|
|
|
*
|
2010-02-18 05:08:56 +01:00
|
|
|
* Returns the length of the content. Please note that this value is
|
2013-05-01 10:04:43 +02:00
|
|
|
* not retrieved from {@link HttpContent#content()} but from the
|
2010-02-18 05:08:56 +01:00
|
|
|
* {@code "Content-Length"} header, and thus they are independent from each
|
|
|
|
* other.
|
|
|
|
*
|
|
|
|
* @return the content length or {@code defaultValue} if this message does
|
2011-05-11 11:09:49 +02:00
|
|
|
* not have the {@code "Content-Length"} header or its value is not
|
|
|
|
* a number
|
2010-02-18 05:08:56 +01:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static long getContentLength(HttpMessage message, long defaultValue) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return HttpHeaderUtil.getContentLength(message, defaultValue);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#setContentLength(HttpMessage, long)} instead.
|
2010-05-06 09:50:19 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void setContentLength(HttpMessage message, long length) {
|
2014-10-31 08:48:28 +01:00
|
|
|
HttpHeaderUtil.setContentLength(message, length);
|
2010-01-26 05:31:54 +01:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #get(CharSequence)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Returns the value of the {@code "Host"} header.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static String getHost(HttpMessage message) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return message.headers().get(HttpHeaderNames.HOST);
|
2010-01-26 05:31:54 +01:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #get(CharSequence, String)} instead.
|
|
|
|
*
|
2010-05-06 09:50:19 +02:00
|
|
|
* Returns the value of the {@code "Host"} header. If there is no such
|
|
|
|
* header, the {@code defaultValue} is returned.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static String getHost(HttpMessage message, String defaultValue) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return message.headers().get(HttpHeaderNames.HOST, defaultValue);
|
2010-01-26 05:31:54 +01:00
|
|
|
}
|
|
|
|
|
2010-05-06 09:50:19 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Object)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #setHost(HttpMessage, CharSequence)}
|
2010-05-06 09:50:19 +02:00
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void setHost(HttpMessage message, String value) {
|
2014-10-31 08:48:28 +01:00
|
|
|
message.headers().set(HttpHeaderNames.HOST, value);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Object)} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* Sets the {@code "Host"} header.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void setHost(HttpMessage message, CharSequence value) {
|
2014-10-31 08:48:28 +01:00
|
|
|
message.headers().set(HttpHeaderNames.HOST, value);
|
2010-01-26 05:31:54 +01:00
|
|
|
}
|
2011-05-11 11:09:49 +02:00
|
|
|
|
|
|
|
/**
|
2014-10-31 19:08:59 +01:00
|
|
|
* @deprecated Use {@link #getTimeMillis(CharSequence)} instead.
|
2014-10-31 08:48:28 +01:00
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Returns the value of the {@code "Date"} header.
|
|
|
|
*
|
|
|
|
* @throws ParseException
|
|
|
|
* if there is no such header or the header value is not a formatted date
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static Date getDate(HttpMessage message) throws ParseException {
|
2014-10-31 08:48:28 +01:00
|
|
|
return getDateHeader(message, HttpHeaderNames.DATE);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 19:08:59 +01:00
|
|
|
* @deprecated Use {@link #getTimeMillis(CharSequence, long)} instead.
|
2014-10-31 08:48:28 +01:00
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Returns the value of the {@code "Date"} header. If there is no such
|
|
|
|
* header or the header is not a formatted date, the {@code defaultValue}
|
|
|
|
* is returned.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static Date getDate(HttpMessage message, Date defaultValue) {
|
2014-10-31 19:08:59 +01:00
|
|
|
return getDateHeader(message, HttpHeaderNames.DATE, defaultValue);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link #set(CharSequence, Object)} instead.
|
|
|
|
*
|
2011-05-11 11:09:49 +02:00
|
|
|
* Sets the {@code "Date"} header.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void setDate(HttpMessage message, Date value) {
|
2014-10-31 08:48:28 +01:00
|
|
|
message.headers().set(HttpHeaderNames.DATE, value);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
2010-01-26 05:31:54 +01:00
|
|
|
|
2010-10-17 20:34:03 +02:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#is100ContinueExpected(HttpMessage)} instead.
|
|
|
|
*
|
2010-10-17 20:34:03 +02:00
|
|
|
* Returns {@code true} if and only if the specified message contains the
|
|
|
|
* {@code "Expect: 100-continue"} header.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static boolean is100ContinueExpected(HttpMessage message) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return HttpHeaderUtil.is100ContinueExpected(message);
|
2010-10-17 20:34:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#set100ContinueExpected(HttpMessage, boolean)} instead.
|
|
|
|
*
|
2010-10-17 20:34:03 +02:00
|
|
|
* Sets the {@code "Expect: 100-continue"} header to the specified message.
|
|
|
|
* If there is any existing {@code "Expect"} header, they are replaced with
|
|
|
|
* the new one.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void set100ContinueExpected(HttpMessage message) {
|
2014-10-31 08:48:28 +01:00
|
|
|
HttpHeaderUtil.set100ContinueExpected(message, true);
|
2010-10-17 20:34:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#set100ContinueExpected(HttpMessage, boolean)} instead.
|
|
|
|
*
|
2010-10-17 20:34:03 +02:00
|
|
|
* Sets or removes the {@code "Expect: 100-continue"} header to / from the
|
|
|
|
* specified message. If the specified {@code value} is {@code true},
|
|
|
|
* the {@code "Expect: 100-continue"} header is set and all other previous
|
|
|
|
* {@code "Expect"} headers are removed. Otherwise, all {@code "Expect"}
|
|
|
|
* headers are removed completely.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void set100ContinueExpected(HttpMessage message, boolean set) {
|
2014-10-31 08:48:28 +01:00
|
|
|
HttpHeaderUtil.set100ContinueExpected(message, set);
|
2010-10-17 20:34:03 +02:00
|
|
|
}
|
|
|
|
|
2013-01-14 16:52:30 +01:00
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link HttpHeaderUtil#isTransferEncodingChunked(HttpMessage)} instead.
|
|
|
|
*
|
2013-01-16 05:22:50 +01:00
|
|
|
* Checks to see if the transfer encoding in a specified {@link HttpMessage} is chunked
|
2013-01-14 16:52:30 +01:00
|
|
|
*
|
|
|
|
* @param message The message to check
|
|
|
|
* @return True if transfer encoding is chunked, otherwise false
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static boolean isTransferEncodingChunked(HttpMessage message) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return HttpHeaderUtil.isTransferEncodingChunked(message);
|
2013-01-14 16:52:30 +01:00
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
/**
|
|
|
|
* @deprecated Use {@link HttpHeaderUtil#setTransferEncodingChunked(HttpMessage, boolean)} instead.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void removeTransferEncodingChunked(HttpMessage m) {
|
2014-10-31 08:48:28 +01:00
|
|
|
HttpHeaderUtil.setTransferEncodingChunked(m, false);
|
2013-01-14 16:52:30 +01:00
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
/**
|
|
|
|
* @deprecated Use {@link HttpHeaderUtil#setTransferEncodingChunked(HttpMessage, boolean)} instead.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static void setTransferEncodingChunked(HttpMessage m) {
|
2014-10-31 08:48:28 +01:00
|
|
|
HttpHeaderUtil.setTransferEncodingChunked(m, true);
|
2013-01-14 16:52:30 +01:00
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
/**
|
|
|
|
* @deprecated Use {@link HttpHeaderUtil#isContentLengthSet(HttpMessage)} instead.
|
|
|
|
*/
|
|
|
|
@Deprecated
|
2013-01-16 05:22:50 +01:00
|
|
|
public static boolean isContentLengthSet(HttpMessage m) {
|
2014-10-31 08:48:28 +01:00
|
|
|
return HttpHeaderUtil.isContentLengthSet(m);
|
2013-01-14 16:52:30 +01:00
|
|
|
}
|
|
|
|
|
2013-11-24 14:32:55 +01:00
|
|
|
/**
|
2014-06-14 10:33:34 +02:00
|
|
|
* @deprecated Use {@link AsciiString#equalsIgnoreCase(CharSequence, CharSequence)} instead.
|
2013-11-24 14:32:55 +01:00
|
|
|
*/
|
2014-06-14 10:33:34 +02:00
|
|
|
@Deprecated
|
2013-11-24 14:32:55 +01:00
|
|
|
public static boolean equalsIgnoreCase(CharSequence name1, CharSequence name2) {
|
2014-06-14 10:33:34 +02:00
|
|
|
return AsciiString.equalsIgnoreCase(name1, name2);
|
2013-11-24 14:32:55 +01:00
|
|
|
}
|
2013-11-28 08:15:14 +01:00
|
|
|
|
2014-09-19 01:04:35 +02:00
|
|
|
static void encode(HttpHeaders headers, ByteBuf buf) throws Exception {
|
2013-11-28 08:15:14 +01:00
|
|
|
if (headers instanceof DefaultHttpHeaders) {
|
|
|
|
((DefaultHttpHeaders) headers).encode(buf);
|
|
|
|
} else {
|
|
|
|
for (Entry<String, String> header: headers) {
|
|
|
|
encode(header.getKey(), header.getValue(), buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-02 12:04:11 +02:00
|
|
|
@SuppressWarnings("deprecation")
|
2014-06-05 11:31:04 +02:00
|
|
|
private static void encode(CharSequence key, CharSequence value, ByteBuf buf) {
|
2013-11-28 08:15:14 +01:00
|
|
|
encodeAscii(key, buf);
|
|
|
|
buf.writeBytes(HEADER_SEPERATOR);
|
|
|
|
encodeAscii(value, buf);
|
|
|
|
buf.writeBytes(CRLF);
|
|
|
|
}
|
|
|
|
|
2014-06-14 10:33:34 +02:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static void encodeAscii(CharSequence seq, ByteBuf buf) {
|
2014-06-05 11:31:04 +02:00
|
|
|
if (seq instanceof AsciiString) {
|
2015-04-01 01:23:52 +02:00
|
|
|
ByteBufUtil.copy((AsciiString) seq, 0, buf, seq.length());
|
2013-11-28 08:15:14 +01:00
|
|
|
} else {
|
|
|
|
encodeAscii0(seq, buf);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encodeAscii0(CharSequence seq, ByteBuf buf) {
|
|
|
|
int length = seq.length();
|
|
|
|
for (int i = 0 ; i < length; i++) {
|
|
|
|
buf.writeByte((byte) seq.charAt(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-10-31 08:48:28 +01:00
|
|
|
* @deprecated Use {@link AsciiString} instead.
|
|
|
|
*
|
2013-11-28 08:15:14 +01:00
|
|
|
* Create a new {@link CharSequence} which is optimized for reuse as {@link HttpHeaders} name or value.
|
|
|
|
* So if you have a Header name or value that you want to reuse you should make use of this.
|
|
|
|
*/
|
2014-10-31 08:48:28 +01:00
|
|
|
@Deprecated
|
2013-11-28 08:15:14 +01:00
|
|
|
public static CharSequence newEntity(String name) {
|
|
|
|
if (name == null) {
|
|
|
|
throw new NullPointerException("name");
|
|
|
|
}
|
2014-06-05 11:31:04 +02:00
|
|
|
return new AsciiString(name);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
protected HttpHeaders() { }
|
2010-01-08 15:11:18 +01:00
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
|
|
|
* @see {@link #get(CharSequence)}
|
|
|
|
*/
|
|
|
|
public abstract String get(String name);
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Returns the value of a header with the specified name. If there are
|
|
|
|
* more than one values for the specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name The name of the header to search
|
|
|
|
* @return The first header value or {@code null} if there is no such header
|
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public String get(CharSequence name) {
|
|
|
|
return get(name.toString());
|
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
/**
|
|
|
|
* Returns the value of a header with the specified name. If there are
|
|
|
|
* more than one values for the specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name The name of the header to search
|
|
|
|
* @return The first header value or {@code defaultValue} if there is no such header
|
|
|
|
*/
|
|
|
|
public String get(CharSequence name, String defaultValue) {
|
|
|
|
String value = get(name);
|
|
|
|
if (value == null) {
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the integer value of a header with the specified name. If there are more than one values for the
|
|
|
|
* specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name the name of the header to search
|
|
|
|
* @return the first header value if the header is found and its value is an integer. {@code null} if there's no
|
|
|
|
* such header or its value is not an integer.
|
|
|
|
*/
|
|
|
|
public abstract Integer getInt(CharSequence name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the integer value of a header with the specified name. If there are more than one values for the
|
|
|
|
* specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name the name of the header to search
|
|
|
|
* @param defaultValue the default value
|
|
|
|
* @return the first header value if the header is found and its value is an integer. {@code defaultValue} if
|
|
|
|
* there's no such header or its value is not an integer.
|
|
|
|
*/
|
|
|
|
public abstract int getInt(CharSequence name, int defaultValue);
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
/**
|
|
|
|
* Returns the short value of a header with the specified name. If there are more than one values for the
|
|
|
|
* specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name the name of the header to search
|
|
|
|
* @return the first header value if the header is found and its value is a short. {@code null} if there's no
|
|
|
|
* such header or its value is not a short.
|
|
|
|
*/
|
|
|
|
public abstract Short getShort(CharSequence name);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the short value of a header with the specified name. If there are more than one values for the
|
|
|
|
* specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name the name of the header to search
|
|
|
|
* @param defaultValue the default value
|
|
|
|
* @return the first header value if the header is found and its value is a short. {@code defaultValue} if
|
|
|
|
* there's no such header or its value is not a short.
|
|
|
|
*/
|
|
|
|
public abstract short getShort(CharSequence name, short defaultValue);
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
/**
|
|
|
|
* Returns the date value of a header with the specified name. If there are more than one values for the
|
|
|
|
* specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name the name of the header to search
|
|
|
|
* @return the first header value if the header is found and its value is a date. {@code null} if there's no
|
|
|
|
* such header or its value is not a date.
|
|
|
|
*/
|
2014-10-31 19:08:59 +01:00
|
|
|
public abstract Long getTimeMillis(CharSequence name);
|
2014-10-31 08:48:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the date value of a header with the specified name. If there are more than one values for the
|
|
|
|
* specified name, the first value is returned.
|
|
|
|
*
|
|
|
|
* @param name the name of the header to search
|
|
|
|
* @param defaultValue the default value
|
|
|
|
* @return the first header value if the header is found and its value is a date. {@code defaultValue} if
|
|
|
|
* there's no such header or its value is not a date.
|
|
|
|
*/
|
2014-10-31 19:08:59 +01:00
|
|
|
public abstract long getTimeMillis(CharSequence name, long defaultValue);
|
2014-10-31 08:48:28 +01:00
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
|
|
|
* @see {@link #getAll(CharSequence)}
|
|
|
|
*/
|
|
|
|
public abstract List<String> getAll(String name);
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Returns the values of headers with the specified name
|
|
|
|
*
|
|
|
|
* @param name The name of the headers to search
|
|
|
|
* @return A {@link List} of header values which will be empty if no values
|
|
|
|
* are found
|
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public List<String> getAll(CharSequence name) {
|
|
|
|
return getAll(name.toString());
|
|
|
|
}
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
2013-12-22 11:16:49 +01:00
|
|
|
* Returns a new {@link List} that contains all headers in this object. Note that modifying the
|
|
|
|
* returned {@link List} will not affect the state of this object. If you intend to enumerate over the header
|
|
|
|
* entries only, use {@link #iterator()} instead, which has much less overhead.
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
|
|
|
public abstract List<Map.Entry<String, String>> entries();
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
|
|
|
* @see {@link #contains(CharSequence)}
|
|
|
|
*/
|
|
|
|
public abstract boolean contains(String name);
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Checks to see if there is a header with the specified name
|
|
|
|
*
|
|
|
|
* @param name The name of the header to search for
|
|
|
|
* @return True if at least one header is found
|
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public boolean contains(CharSequence name) {
|
|
|
|
return contains(name.toString());
|
|
|
|
}
|
2010-01-08 14:29:39 +01:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Checks if no header exists.
|
|
|
|
*/
|
|
|
|
public abstract boolean isEmpty();
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
2013-12-22 11:16:49 +01:00
|
|
|
* Returns a new {@link Set} that contains the names of all headers in this object. Note that modifying the
|
|
|
|
* returned {@link Set} will not affect the state of this object. If you intend to enumerate over the header
|
|
|
|
* entries only, use {@link #iterator()} instead, which has much less overhead.
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
|
|
|
public abstract Set<String> names();
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
|
|
|
* @see {@link #add(CharSequence, Object)}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders add(String name, Object value);
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Adds a new header with the specified name and value.
|
|
|
|
*
|
|
|
|
* If the specified value is not a {@link String}, it is converted
|
|
|
|
* into a {@link String} by {@link Object#toString()}, except in the cases
|
|
|
|
* of {@link Date} and {@link Calendar}, which are formatted to the date
|
|
|
|
* format defined in <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>.
|
|
|
|
*
|
|
|
|
* @param name The name of the header being added
|
|
|
|
* @param value The value of the header being added
|
2013-01-16 15:56:51 +01:00
|
|
|
*
|
|
|
|
* @return {@code this}
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public HttpHeaders add(CharSequence name, Object value) {
|
|
|
|
return add(name.toString(), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see {@link #add(CharSequence, Iterable)}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders add(String name, Iterable<?> values);
|
2010-01-08 14:29:39 +01:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Adds a new header with the specified name and values.
|
|
|
|
*
|
2013-01-30 07:42:18 +01:00
|
|
|
* This getMethod can be represented approximately as the following code:
|
2013-01-16 05:22:50 +01:00
|
|
|
* <pre>
|
|
|
|
* for (Object v: values) {
|
|
|
|
* if (v == null) {
|
|
|
|
* break;
|
|
|
|
* }
|
|
|
|
* headers.add(name, v);
|
|
|
|
* }
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* @param name The name of the headers being set
|
|
|
|
* @param values The values of the headers being set
|
2013-01-16 15:56:51 +01:00
|
|
|
* @return {@code this}
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public HttpHeaders add(CharSequence name, Iterable<?> values) {
|
|
|
|
return add(name.toString(), values);
|
|
|
|
}
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-01-16 15:56:51 +01:00
|
|
|
/**
|
|
|
|
* Adds all header entries of the specified {@code headers}.
|
|
|
|
*
|
|
|
|
* @return {@code this}
|
|
|
|
*/
|
|
|
|
public HttpHeaders add(HttpHeaders headers) {
|
2013-01-16 05:22:50 +01:00
|
|
|
if (headers == null) {
|
|
|
|
throw new NullPointerException("headers");
|
2010-01-08 09:29:37 +01:00
|
|
|
}
|
2013-01-16 05:22:50 +01:00
|
|
|
for (Map.Entry<String, String> e: headers) {
|
|
|
|
add(e.getKey(), e.getValue());
|
2010-01-08 09:29:37 +01:00
|
|
|
}
|
2013-01-16 15:56:51 +01:00
|
|
|
return this;
|
2010-01-08 09:29:37 +01:00
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
/**
|
|
|
|
* Add the {@code name} to {@code value}.
|
|
|
|
* @param name The name to modify
|
|
|
|
* @param value The value
|
|
|
|
* @return {@code this}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders addInt(CharSequence name, int value);
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
/**
|
|
|
|
* Add the {@code name} to {@code value}.
|
|
|
|
* @param name The name to modify
|
|
|
|
* @param value The value
|
|
|
|
* @return {@code this}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders addShort(CharSequence name, short value);
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
|
|
|
* @see {@link #set(CharSequence, Object)}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders set(String name, Object value);
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Sets a header with the specified name and value.
|
|
|
|
*
|
|
|
|
* If there is an existing header with the same name, it is removed.
|
|
|
|
* If the specified value is not a {@link String}, it is converted into a
|
|
|
|
* {@link String} by {@link Object#toString()}, except for {@link Date}
|
|
|
|
* and {@link Calendar}, which are formatted to the date format defined in
|
|
|
|
* <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1">RFC2616</a>.
|
|
|
|
*
|
|
|
|
* @param name The name of the header being set
|
|
|
|
* @param value The value of the header being set
|
2013-01-16 15:56:51 +01:00
|
|
|
* @return {@code this}
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public HttpHeaders set(CharSequence name, Object value) {
|
|
|
|
return set(name.toString(), value);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @see {@link #set(CharSequence, Iterable)}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders set(String name, Iterable<?> values);
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Sets a header with the specified name and values.
|
|
|
|
*
|
|
|
|
* If there is an existing header with the same name, it is removed.
|
2013-01-30 07:42:18 +01:00
|
|
|
* This getMethod can be represented approximately as the following code:
|
2013-01-16 05:22:50 +01:00
|
|
|
* <pre>
|
|
|
|
* headers.remove(name);
|
|
|
|
* for (Object v: values) {
|
|
|
|
* if (v == null) {
|
|
|
|
* break;
|
|
|
|
* }
|
|
|
|
* headers.add(name, v);
|
|
|
|
* }
|
|
|
|
* </pre>
|
|
|
|
*
|
|
|
|
* @param name The name of the headers being set
|
|
|
|
* @param values The values of the headers being set
|
2013-01-16 15:56:51 +01:00
|
|
|
* @return {@code this}
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public HttpHeaders set(CharSequence name, Iterable<?> values) {
|
|
|
|
return set(name.toString(), values);
|
|
|
|
}
|
2010-01-08 09:29:37 +01:00
|
|
|
|
2013-01-16 15:56:51 +01:00
|
|
|
/**
|
|
|
|
* Cleans the current header entries and copies all header entries of the specified {@code headers}.
|
|
|
|
*
|
|
|
|
* @return {@code this}
|
|
|
|
*/
|
|
|
|
public HttpHeaders set(HttpHeaders headers) {
|
2015-01-20 01:48:11 +01:00
|
|
|
checkNotNull(headers, "headers");
|
2014-06-04 11:34:57 +02:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
clear();
|
2015-01-20 01:48:11 +01:00
|
|
|
|
2014-06-04 11:34:57 +02:00
|
|
|
if (headers.isEmpty()) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
try {
|
|
|
|
headers.forEachEntry(addAllVisitor());
|
|
|
|
} catch (Exception e) {
|
|
|
|
PlatformDependent.throwException(e);
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Retains all current headers but calls {@link #set(String, Object)} for each entry in {@code headers}
|
|
|
|
*
|
|
|
|
* @param headers The headers used to {@link #set(String, Object)} values in this instance
|
|
|
|
* @return {@code this}
|
|
|
|
*/
|
|
|
|
public HttpHeaders setAll(HttpHeaders headers) {
|
|
|
|
checkNotNull(headers, "headers");
|
|
|
|
|
|
|
|
if (headers.isEmpty()) {
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
headers.forEachEntry(setAllVisitor());
|
|
|
|
} catch (Exception e) {
|
|
|
|
PlatformDependent.throwException(e);
|
2011-05-11 11:09:49 +02:00
|
|
|
}
|
2013-01-16 15:56:51 +01:00
|
|
|
return this;
|
2010-01-26 05:31:54 +01:00
|
|
|
}
|
|
|
|
|
2014-10-31 08:48:28 +01:00
|
|
|
/**
|
|
|
|
* Set the {@code name} to {@code value}. This will remove all previous values associated with {@code name}.
|
|
|
|
* @param name The name to modify
|
|
|
|
* @param value The value
|
|
|
|
* @return {@code this}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders setInt(CharSequence name, int value);
|
|
|
|
|
2015-01-20 01:48:11 +01:00
|
|
|
/**
|
|
|
|
* Set the {@code name} to {@code value}. This will remove all previous values associated with {@code name}.
|
|
|
|
* @param name The name to modify
|
|
|
|
* @param value The value
|
|
|
|
* @return {@code this}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders setShort(CharSequence name, short value);
|
|
|
|
|
2013-11-28 08:15:14 +01:00
|
|
|
/**
|
|
|
|
* @see {@link #remove(CharSequence)}
|
|
|
|
*/
|
|
|
|
public abstract HttpHeaders remove(String name);
|
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Removes the header with the specified name.
|
|
|
|
*
|
|
|
|
* @param name The name of the header to remove
|
2013-01-16 15:56:51 +01:00
|
|
|
* @return {@code this}
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
2013-11-28 08:15:14 +01:00
|
|
|
public HttpHeaders remove(CharSequence name) {
|
|
|
|
return remove(name.toString());
|
|
|
|
}
|
2010-05-04 03:46:15 +02:00
|
|
|
|
2013-01-16 05:22:50 +01:00
|
|
|
/**
|
|
|
|
* Removes all headers from this {@link HttpMessage}.
|
2013-01-16 15:56:51 +01:00
|
|
|
*
|
|
|
|
* @return {@code this}
|
2013-01-16 05:22:50 +01:00
|
|
|
*/
|
2013-01-16 15:56:51 +01:00
|
|
|
public abstract HttpHeaders clear();
|
2013-10-11 21:28:02 +02:00
|
|
|
|
|
|
|
/**
|
2013-11-28 08:15:14 +01:00
|
|
|
* @see {@link #contains(CharSequence, CharSequence, boolean)}
|
2013-10-11 21:28:02 +02:00
|
|
|
*/
|
2014-06-05 11:31:04 +02:00
|
|
|
public boolean contains(String name, String value, boolean ignoreCase) {
|
2013-10-11 21:28:02 +02:00
|
|
|
List<String> values = getAll(name);
|
|
|
|
if (values.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (String v: values) {
|
2014-06-05 11:31:04 +02:00
|
|
|
if (ignoreCase) {
|
2014-10-31 08:48:28 +01:00
|
|
|
if (v.equalsIgnoreCase(value)) {
|
2013-10-11 21:28:02 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (v.equals(value)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2013-11-28 08:15:14 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns {@code true} if a header with the name and value exists.
|
|
|
|
*
|
2014-06-05 11:31:04 +02:00
|
|
|
* @param name the headername
|
|
|
|
* @param value the value
|
|
|
|
* @param ignoreCase {@code true} if case should be ignored
|
|
|
|
* @return contains {@code true} if it contains it {@code false} otherwise
|
2013-11-28 08:15:14 +01:00
|
|
|
*/
|
2014-06-05 11:31:04 +02:00
|
|
|
public boolean contains(CharSequence name, CharSequence value, boolean ignoreCase) {
|
|
|
|
return contains(name.toString(), value.toString(), ignoreCase);
|
2013-11-28 08:15:14 +01:00
|
|
|
}
|
2015-01-20 01:48:11 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide a means of iterating over elements in this map with low GC
|
|
|
|
*
|
|
|
|
* @param visitor The visitor which will visit each element in this map
|
|
|
|
* @return The last entry before iteration stopped or {@code null} if iteration went past the end
|
|
|
|
*/
|
|
|
|
public abstract Map.Entry<CharSequence, CharSequence> forEachEntry(EntryVisitor<CharSequence> visitor)
|
|
|
|
throws Exception;
|
|
|
|
|
|
|
|
private EntryVisitor<CharSequence> setAllVisitor() {
|
|
|
|
return new EntryVisitor<CharSequence>() {
|
|
|
|
@Override
|
|
|
|
public boolean visit(Entry<CharSequence, CharSequence> entry) {
|
|
|
|
set(entry.getKey(), entry.getValue());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
private EntryVisitor<CharSequence> addAllVisitor() {
|
|
|
|
return new EntryVisitor<CharSequence>() {
|
|
|
|
@Override
|
|
|
|
public boolean visit(Entry<CharSequence, CharSequence> entry) {
|
|
|
|
add(entry.getKey(), entry.getValue());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2008-11-19 08:22:15 +01:00
|
|
|
}
|