Class DefaultHttpHeaders
- java.lang.Object
-
- org.jboss.netty.handler.codec.http.HttpHeaders
-
- org.jboss.netty.handler.codec.http.DefaultHttpHeaders
-
- All Implemented Interfaces:
java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>
- Direct Known Subclasses:
DefaultHttpChunkTrailer.TrailingHeaders
public class DefaultHttpHeaders extends HttpHeaders
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classDefaultHttpHeaders.HeaderEntryprivate classDefaultHttpHeaders.HeaderIterator-
Nested classes/interfaces inherited from class org.jboss.netty.handler.codec.http.HttpHeaders
HttpHeaders.Names, HttpHeaders.Values
-
-
Field Summary
Fields Modifier and Type Field Description private static intBUCKET_SIZEprivate DefaultHttpHeaders.HeaderEntry[]entriesprivate DefaultHttpHeaders.HeaderEntryheadprivate static java.util.Set<java.lang.String>KNOWN_NAMESprivate static java.util.Set<java.lang.String>KNOWN_VALUESprotected booleanvalidate-
Fields inherited from class org.jboss.netty.handler.codec.http.HttpHeaders
EMPTY_HEADERS
-
-
Constructor Summary
Constructors Constructor Description DefaultHttpHeaders()DefaultHttpHeaders(boolean validate)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpHeadersadd(java.lang.String name, java.lang.Iterable<?> values)Adds a new header with the specified name and values.HttpHeadersadd(java.lang.String name, java.lang.Object value)Adds a new header with the specified name and value.private voidadd0(int h, int i, java.lang.String name, java.lang.String value)HttpHeadersclear()Removes all headers from thisHttpMessage.booleancontains(java.lang.String name)Checks to see if there is a header with the specified namebooleancontains(java.lang.String name, java.lang.String value, boolean ignoreCaseValue)Returnstrueif a header with the name and value exists.private static java.util.Set<java.lang.String>createSet(java.lang.Class<?> clazz)java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>>entries()Returns a newListthat contains all headers in this object.private static booleaneq(java.lang.String name1, java.lang.String name2)java.lang.Stringget(java.lang.String name)Returns the value of a header with the specified name.private java.lang.Stringget(java.lang.String name, boolean last)java.util.List<java.lang.String>getAll(java.lang.String name)Returns the values of headers with the specified nameprivate static inthash(java.lang.String name, boolean validate)private static intindex(int hash)booleanisEmpty()Checks if no header exists.java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>>iterator()java.util.Set<java.lang.String>names()Returns a newSetthat contains the names of all headers in this object.HttpHeadersremove(java.lang.String name)Removes the header with the specified name.private voidremove0(int h, int i, java.lang.String name)HttpHeadersset(java.lang.String name, java.lang.Iterable<?> values)Sets a header with the specified name and values.HttpHeadersset(java.lang.String name, java.lang.Object value)Sets a header with the specified name and value.private static chartoLowerCase(char c)private static java.lang.StringtoString(java.lang.Object value)(package private) voidvalidateHeaderValue0(java.lang.String headerValue)-
Methods inherited from class org.jboss.netty.handler.codec.http.HttpHeaders
add, addDateHeader, addHeader, addIntHeader, clearHeaders, getContentLength, getContentLength, getDate, getDate, getDateHeader, getDateHeader, getHeader, getHeader, getHost, getHost, getIntHeader, getIntHeader, is100ContinueExpected, isContentLengthSet, isKeepAlive, isTransferEncodingChunked, removeHeader, removeTransferEncodingChunked, set, set100ContinueExpected, set100ContinueExpected, setContentLength, setDate, setDateHeader, setDateHeader, setHeader, setHeader, setHost, setIntHeader, setIntHeader, setKeepAlive, setTransferEncodingChunked, validateHeaderName, validateHeaderValue, valideHeaderNameChar
-
-
-
-
Field Detail
-
BUCKET_SIZE
private static final int BUCKET_SIZE
- See Also:
- Constant Field Values
-
KNOWN_NAMES
private static final java.util.Set<java.lang.String> KNOWN_NAMES
-
KNOWN_VALUES
private static final java.util.Set<java.lang.String> KNOWN_VALUES
-
entries
private final DefaultHttpHeaders.HeaderEntry[] entries
-
head
private final DefaultHttpHeaders.HeaderEntry head
-
validate
protected final boolean validate
-
-
Method Detail
-
createSet
private static java.util.Set<java.lang.String> createSet(java.lang.Class<?> clazz)
-
hash
private static int hash(java.lang.String name, boolean validate)
-
eq
private static boolean eq(java.lang.String name1, java.lang.String name2)
-
toLowerCase
private static char toLowerCase(char c)
-
index
private static int index(int hash)
-
validateHeaderValue0
void validateHeaderValue0(java.lang.String headerValue)
-
add
public HttpHeaders add(java.lang.String name, java.lang.Object value)
Description copied from class:HttpHeadersAdds a new header with the specified name and value. If the specified value is not aString, it is converted into aStringbyObject.toString(), except in the cases ofDateandCalendar, which are formatted to the date format defined in RFC2616.- Specified by:
addin classHttpHeaders- Parameters:
name- The name of the header being addedvalue- The value of the header being added- Returns:
this
-
add
public HttpHeaders add(java.lang.String name, java.lang.Iterable<?> values)
Description copied from class:HttpHeadersAdds a new header with the specified name and values. This getMethod can be represented approximately as the following code:for (Object v: values) { if (v == null) { break; } headers.add(name, v); }- Specified by:
addin classHttpHeaders- Parameters:
name- The name of the headers being setvalues- The values of the headers being set- Returns:
this
-
add0
private void add0(int h, int i, java.lang.String name, java.lang.String value)
-
remove
public HttpHeaders remove(java.lang.String name)
Description copied from class:HttpHeadersRemoves the header with the specified name.- Specified by:
removein classHttpHeaders- Parameters:
name- The name of the header to remove- Returns:
this
-
remove0
private void remove0(int h, int i, java.lang.String name)
-
set
public HttpHeaders set(java.lang.String name, java.lang.Object value)
Description copied from class:HttpHeadersSets 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 aString, it is converted into aStringbyObject.toString(), except forDateandCalendar, which are formatted to the date format defined in RFC2616.- Specified by:
setin classHttpHeaders- Parameters:
name- The name of the header being setvalue- The value of the header being set- Returns:
this
-
set
public HttpHeaders set(java.lang.String name, java.lang.Iterable<?> values)
Description copied from class:HttpHeadersSets a header with the specified name and values. If there is an existing header with the same name, it is removed. This getMethod can be represented approximately as the following code:headers.remove(name); for (Object v: values) { if (v == null) { break; } headers.add(name, v); }- Specified by:
setin classHttpHeaders- Parameters:
name- The name of the headers being setvalues- The values of the headers being set- Returns:
this
-
clear
public HttpHeaders clear()
Description copied from class:HttpHeadersRemoves all headers from thisHttpMessage.- Specified by:
clearin classHttpHeaders- Returns:
this
-
get
public java.lang.String get(java.lang.String name)
Description copied from class:HttpHeadersReturns 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.- Specified by:
getin classHttpHeaders- Parameters:
name- The name of the header to search- Returns:
- The first header value or
nullif there is no such header
-
get
private java.lang.String get(java.lang.String name, boolean last)
-
getAll
public java.util.List<java.lang.String> getAll(java.lang.String name)
Description copied from class:HttpHeadersReturns the values of headers with the specified name- Specified by:
getAllin classHttpHeaders- Parameters:
name- The name of the headers to search- Returns:
- A
Listof header values which will be empty if no values are found
-
entries
public java.util.List<java.util.Map.Entry<java.lang.String,java.lang.String>> entries()
Description copied from class:HttpHeadersReturns a newListthat contains all headers in this object. Note that modifying the returnedListwill not affect the state of this object. If you intend to enumerate over the header entries only, useIterable.iterator()instead, which has much less overhead.- Specified by:
entriesin classHttpHeaders
-
iterator
public java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> iterator()
-
contains
public boolean contains(java.lang.String name)
Description copied from class:HttpHeadersChecks to see if there is a header with the specified name- Specified by:
containsin classHttpHeaders- Parameters:
name- The name of the header to search for- Returns:
- True if at least one header is found
-
isEmpty
public boolean isEmpty()
Description copied from class:HttpHeadersChecks if no header exists.- Specified by:
isEmptyin classHttpHeaders
-
contains
public boolean contains(java.lang.String name, java.lang.String value, boolean ignoreCaseValue)Description copied from class:HttpHeadersReturnstrueif a header with the name and value exists.- Overrides:
containsin classHttpHeaders- Parameters:
name- the headernamevalue- the valueignoreCaseValue-trueif case should be ignored- Returns:
- contains
trueif it contains itfalseotherwise
-
names
public java.util.Set<java.lang.String> names()
Description copied from class:HttpHeadersReturns a newSetthat contains the names of all headers in this object. Note that modifying the returnedSetwill not affect the state of this object. If you intend to enumerate over the header entries only, useIterable.iterator()instead, which has much less overhead.- Specified by:
namesin classHttpHeaders
-
toString
private static java.lang.String toString(java.lang.Object value)
-
-