@UnstableApi public final class ReadOnlyHttpHeaders extends HttpHeaders
HttpHeaders which only supports read-only methods.
 Any array passed to this class may be used directly in the underlying data structures of this class. If these arrays may be modified it is the caller's responsibility to supply this class with a copy of the array.
 This may be a good alternative to DefaultHttpHeaders if your have a fixed set of headers which will not
 change.
HttpHeaders.Names, HttpHeaders.ValuesEMPTY_HEADERS| Constructor and Description | 
|---|
| ReadOnlyHttpHeaders(boolean validateHeaders,
                   CharSequence... nameValuePairs)Create a new instance. | 
| Modifier and Type | Method and Description | 
|---|---|
| HttpHeaders | add(String name,
   Iterable<?> values) | 
| HttpHeaders | add(String name,
   Object value) | 
| HttpHeaders | addInt(CharSequence name,
      int value)Add the  nametovalue. | 
| HttpHeaders | addShort(CharSequence name,
        short value)Add the  nametovalue. | 
| HttpHeaders | clear()Removes all headers from this  HttpMessage. | 
| boolean | contains(String name) | 
| boolean | contains(String name,
        String value,
        boolean ignoreCase) | 
| boolean | containsValue(CharSequence name,
             CharSequence value,
             boolean ignoreCase)Returns  trueif a header with thenameandvalueexists,falseotherwise. | 
| List<Map.Entry<String,String>> | entries()Returns a new  Listthat contains all headers in this object. | 
| String | get(String name) | 
| List<String> | getAll(String name) | 
| Integer | getInt(CharSequence name)Returns the integer value of a header with the specified name. | 
| int | getInt(CharSequence name,
      int defaultValue)Returns the integer value of a header with the specified name. | 
| Short | getShort(CharSequence name)Returns the short value of a header with the specified name. | 
| short | getShort(CharSequence name,
        short defaultValue)Returns the short value of a header with the specified name. | 
| Long | getTimeMillis(CharSequence name)Returns the date value of a header with the specified name. | 
| long | getTimeMillis(CharSequence name,
             long defaultValue)Returns the date value of a header with the specified name. | 
| boolean | isEmpty()Checks if no header exists. | 
| Iterator<Map.Entry<String,String>> | iterator() | 
| Iterator<Map.Entry<CharSequence,CharSequence>> | iteratorCharSequence() | 
| Set<String> | names()Returns a new  Setthat contains the names of all headers in this object. | 
| HttpHeaders | remove(String name) | 
| HttpHeaders | set(String name,
   Iterable<?> values) | 
| HttpHeaders | set(String name,
   Object value) | 
| HttpHeaders | setInt(CharSequence name,
      int value)Set the  nametovalue. | 
| HttpHeaders | setShort(CharSequence name,
        short value)Set the  nametovalue. | 
| int | size()Returns the number of headers in this object. | 
| Iterator<CharSequence> | valueCharSequenceIterator(CharSequence name)Equivalent to  HttpHeaders.getAll(String)but it is possible that no intermediate list is generated. | 
| Iterator<String> | valueStringIterator(CharSequence name)Equivalent to  HttpHeaders.getAll(String)but it is possible that no intermediate list is generated. | 
add, add, add, addDateHeader, addDateHeader, addHeader, addHeader, addIntHeader, addIntHeader, clearHeaders, contains, contains, copy, encodeAscii, equalsIgnoreCase, get, get, getAll, getAllAsString, getAsString, getContentLength, getContentLength, getDate, getDate, getDateHeader, getDateHeader, getDateHeader, getDateHeader, getHeader, getHeader, getHeader, getHeader, getHost, getHost, getIntHeader, getIntHeader, getIntHeader, getIntHeader, is100ContinueExpected, isContentLengthSet, isKeepAlive, isTransferEncodingChunked, iteratorAsString, newEntity, remove, removeHeader, removeHeader, removeTransferEncodingChunked, set, set, set, set100ContinueExpected, set100ContinueExpected, setAll, setContentLength, setDate, setDateHeader, setDateHeader, setDateHeader, setDateHeader, setHeader, setHeader, setHeader, setHeader, setHost, setHost, setIntHeader, setIntHeader, setIntHeader, setIntHeader, setKeepAlive, setTransferEncodingChunked, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic ReadOnlyHttpHeaders(boolean validateHeaders,
                           CharSequence... nameValuePairs)
validateHeaders - true to validate the contents of each header name.nameValuePairs - An array of the structure [<name,value>,<name,value>,...].
                      A copy will NOT be made of this array. If the contents of this array
                      may be modified externally you are responsible for passing in a copy.public String get(String name)
get in class HttpHeadersHttpHeaders.get(CharSequence)public Integer getInt(CharSequence name)
HttpHeadersgetInt in class HttpHeadersname - the name of the header to searchnull if there's no
         such header or its value is not an integer.public int getInt(CharSequence name, int defaultValue)
HttpHeadersgetInt in class HttpHeadersname - the name of the header to searchdefaultValue - the default valuedefaultValue if
         there's no such header or its value is not an integer.public Short getShort(CharSequence name)
HttpHeadersgetShort in class HttpHeadersname - the name of the header to searchnull if there's no
         such header or its value is not a short.public short getShort(CharSequence name, short defaultValue)
HttpHeadersgetShort in class HttpHeadersname - the name of the header to searchdefaultValue - the default valuedefaultValue if
         there's no such header or its value is not a short.public Long getTimeMillis(CharSequence name)
HttpHeadersgetTimeMillis in class HttpHeadersname - the name of the header to searchnull if there's no
         such header or its value is not a date.public long getTimeMillis(CharSequence name, long defaultValue)
HttpHeadersgetTimeMillis in class HttpHeadersname - the name of the header to searchdefaultValue - the default valuedefaultValue if
         there's no such header or its value is not a date.public List<String> getAll(String name)
getAll in class HttpHeadersHttpHeaders.getAll(CharSequence)public List<Map.Entry<String,String>> entries()
HttpHeadersList that contains all headers in this object.  Note that modifying the
 returned List will not affect the state of this object.  If you intend to enumerate over the header
 entries only, use HttpHeaders.iterator() instead, which has much less overhead.entries in class HttpHeadersHttpHeaders.iteratorCharSequence()public boolean contains(String name)
contains in class HttpHeadersHttpHeaders.contains(CharSequence)public boolean contains(String name, String value, boolean ignoreCase)
contains in class HttpHeadersHttpHeaders.contains(CharSequence, CharSequence, boolean)public boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase)
HttpHeaderstrue if a header with the name and value exists, false otherwise.
 This also handles multiple values that are separated with a ,.
 
 If ignoreCase is true then a case insensitive compare is done on the value.
containsValue in class HttpHeadersname - the name of the header to findvalue - the value of the header to findignoreCase - true then a case insensitive compare is run to compare values.
 otherwise a case sensitive compare is run to compare values.public Iterator<String> valueStringIterator(CharSequence name)
HttpHeadersHttpHeaders.getAll(String) but it is possible that no intermediate list is generated.valueStringIterator in class HttpHeadersname - the name of the header to retrieveIterator of header values corresponding to name.public Iterator<CharSequence> valueCharSequenceIterator(CharSequence name)
HttpHeadersHttpHeaders.getAll(String) but it is possible that no intermediate list is generated.valueCharSequenceIterator in class HttpHeadersname - the name of the header to retrieveIterator of header values corresponding to name.public Iterator<Map.Entry<CharSequence,CharSequence>> iteratorCharSequence()
iteratorCharSequence in class HttpHeaderspublic boolean isEmpty()
HttpHeadersisEmpty in class HttpHeaderspublic int size()
HttpHeaderssize in class HttpHeaderspublic Set<String> names()
HttpHeadersSet that contains the names of all headers in this object.  Note that modifying the
 returned Set will not affect the state of this object.  If you intend to enumerate over the header
 entries only, use HttpHeaders.iterator() instead, which has much less overhead.names in class HttpHeaderspublic HttpHeaders add(String name, Object value)
add in class HttpHeadersHttpHeaders.add(CharSequence, Object)public HttpHeaders add(String name, Iterable<?> values)
add in class HttpHeadersHttpHeaders.add(CharSequence, Iterable)public HttpHeaders addInt(CharSequence name, int value)
HttpHeadersname to value.addInt in class HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders addShort(CharSequence name, short value)
HttpHeadersname to value.addShort in class HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders set(String name, Object value)
set in class HttpHeadersHttpHeaders.set(CharSequence, Object)public HttpHeaders set(String name, Iterable<?> values)
set in class HttpHeadersHttpHeaders.set(CharSequence, Iterable)public HttpHeaders setInt(CharSequence name, int value)
HttpHeadersname to value. This will remove all previous values associated with name.setInt in class HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders setShort(CharSequence name, short value)
HttpHeadersname to value. This will remove all previous values associated with name.setShort in class HttpHeadersname - The name to modifyvalue - The valuethispublic HttpHeaders remove(String name)
remove in class HttpHeadersHttpHeaders.remove(CharSequence)public HttpHeaders clear()
HttpHeadersHttpMessage.clear in class HttpHeadersthisCopyright © 2008–2025 The Netty Project. All rights reserved.