GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Overview
  • Use
  • Tree
  • Deprecated
  • Index
  • Search
  • Help
  • io.netty.handler.codec.http
  • HttpHeaders

This view

  • Original page
  • New address

GeezerVison is showing netty.io — HttpHeaders (Netty API Reference (4.1.141.Final))

Class HttpHeaders

java.lang.Object
io.netty.handler.codec.http.HttpHeaders
All Implemented Interfaces:
Iterable<Map.Entry<String,String>>
Direct Known Subclasses:
DefaultHttpHeaders, EmptyHttpHeaders, ReadOnlyHttpHeaders

public abstract class HttpHeaders extends Object implements Iterable<Map.Entry<String,String>>
Provides the constants for the standard HTTP header names and values and commonly used utility methods that accesses an HttpMessage.

Concrete instances of this class are most easily obtained from its default factory: DefaultHttpHeadersFactory.headersFactory().

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    HttpHeaders.Names
    Deprecated.
    Use HttpHeaderNames instead.
    static final class 
    HttpHeaders.Values
    Deprecated.
    Use HttpHeaderValues instead.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HttpHeaders
    EMPTY_HEADERS
    Deprecated.
    Use EmptyHttpHeaders.INSTANCE.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    HttpHeaders()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    HttpHeaders
    add(HttpHeaders headers)
    Adds all header entries of the specified headers.
    HttpHeaders
    add(CharSequence name, Iterable<?> values)
    Adds a new header with the specified name and values.
    HttpHeaders
    add(CharSequence name, Object value)
    Adds a new header with the specified name and value.
    abstract HttpHeaders
    add(String name, Iterable<?> values)
     
    abstract HttpHeaders
    add(String name, Object value)
     
    static void
    addDateHeader(HttpMessage message, CharSequence name, Date value)
    Deprecated.
    Use add(CharSequence, Object) instead.
    static void
    addDateHeader(HttpMessage message, String name, Date value)
    Deprecated.
    Use add(CharSequence, Object) instead.
    static void
    addHeader(HttpMessage message, CharSequence name, Object value)
    Deprecated.
    Use add(CharSequence, Object) instead.
    static void
    addHeader(HttpMessage message, String name, Object value)
    Deprecated.
    Use add(CharSequence, Object) instead.
    abstract HttpHeaders
    addInt(CharSequence name, int value)
    Add the name to value.
    static void
    addIntHeader(HttpMessage message, CharSequence name, int value)
    Deprecated.
    Use addInt(CharSequence, int) instead.
    static void
    addIntHeader(HttpMessage message, String name, int value)
    Deprecated.
    Use add(CharSequence, Iterable) instead.
    abstract HttpHeaders
    addShort(CharSequence name, short value)
    Add the name to value.
    abstract HttpHeaders
    clear()
    Removes all headers from this HttpMessage.
    static void
    clearHeaders(HttpMessage message)
    Deprecated.
    Use clear() instead.
    boolean
    contains(CharSequence name)
    Checks to see if there is a header with the specified name
    boolean
    contains(CharSequence name, CharSequence value, boolean ignoreCase)
    Returns true if a header with the name and value exists, false otherwise.
    abstract boolean
    contains(String name)
     
    boolean
    contains(String name, String value, boolean ignoreCase)
     
    boolean
    containsValue(CharSequence name, CharSequence value, boolean ignoreCase)
    Returns true if a header with the name and value exists, false otherwise.
    HttpHeaders
    copy()
    Returns a deep copy of the passed in HttpHeaders.
    static void
    encodeAscii(CharSequence seq, ByteBuf buf)
    Deprecated.
    abstract List<Map.Entry<String,String>>
    entries()
    Returns a new List that contains all headers in this object.
    static boolean
    equalsIgnoreCase(CharSequence name1, CharSequence name2)
    Deprecated.
    Use AsciiString.contentEqualsIgnoreCase(CharSequence, CharSequence) instead.
    String
    get(CharSequence name)
    Returns the value of a header with the specified name.
    String
    get(CharSequence name, String defaultValue)
    Returns the value of a header with the specified name.
    abstract String
    get(String name)
     
    List<String>
    getAll(CharSequence name)
    Returns the values of headers with the specified name
    abstract List<String>
    getAll(String name)
     
    final List<String>
    getAllAsString(CharSequence name)
    Headers.getAll(Object) and convert each element of List to a String.
    final String
    getAsString(CharSequence name)
    Headers.get(Object) and convert the result to a String.
    static long
    getContentLength(HttpMessage message)
    Deprecated.
    Use HttpUtil.getContentLength(HttpMessage) instead.
    static long
    getContentLength(HttpMessage message, long defaultValue)
    Deprecated.
    Use HttpUtil.getContentLength(HttpMessage, long) instead.
    static Date
    getDate(HttpMessage message)
    Deprecated.
    Use getTimeMillis(CharSequence) instead.
    static Date
    getDate(HttpMessage message, Date defaultValue)
    Deprecated.
    Use getTimeMillis(CharSequence, long) instead.
    static Date
    getDateHeader(HttpMessage message, CharSequence name)
    Deprecated.
    Use getTimeMillis(CharSequence) instead.
    static Date
    getDateHeader(HttpMessage message, CharSequence name, Date defaultValue)
    Deprecated.
    Use getTimeMillis(CharSequence, long) instead.
    static Date
    getDateHeader(HttpMessage message, String name)
    Deprecated.
    Use getTimeMillis(CharSequence) instead.
    static Date
    getDateHeader(HttpMessage message, String name, Date defaultValue)
    Deprecated.
    Use getTimeMillis(CharSequence, long) instead.
    static String
    getHeader(HttpMessage message, CharSequence name)
    Deprecated.
    Use get(CharSequence) instead.
    static String
    getHeader(HttpMessage message, CharSequence name, String defaultValue)
    Deprecated.
    Use get(CharSequence, String) instead.
    static String
    getHeader(HttpMessage message, String name)
    Deprecated.
    Use get(CharSequence) instead.
    static String
    getHeader(HttpMessage message, String name, String defaultValue)
    Deprecated.
    Use get(CharSequence, String) instead.
    static String
    getHost(HttpMessage message)
    Deprecated.
    Use get(CharSequence) instead.
    static String
    getHost(HttpMessage message, String defaultValue)
    Deprecated.
    Use get(CharSequence, String) instead.
    abstract Integer
    getInt(CharSequence name)
    Returns the integer value of a header with the specified name.
    abstract int
    getInt(CharSequence name, int defaultValue)
    Returns the integer value of a header with the specified name.
    static int
    getIntHeader(HttpMessage message, CharSequence name)
    Deprecated.
    Use getInt(CharSequence) instead.
    static int
    getIntHeader(HttpMessage message, CharSequence name, int defaultValue)
    Deprecated.
    Use getInt(CharSequence, int) instead.
    static int
    getIntHeader(HttpMessage message, String name)
    Deprecated.
    Use getInt(CharSequence) instead.
    static int
    getIntHeader(HttpMessage message, String name, int defaultValue)
    Deprecated.
    Use getInt(CharSequence, int) instead.
    abstract Short
    getShort(CharSequence name)
    Returns the short value of a header with the specified name.
    abstract short
    getShort(CharSequence name, short defaultValue)
    Returns the short value of a header with the specified name.
    abstract Long
    getTimeMillis(CharSequence name)
    Returns the date value of a header with the specified name.
    abstract long
    getTimeMillis(CharSequence name, long defaultValue)
    Returns the date value of a header with the specified name.
    static boolean
    is100ContinueExpected(HttpMessage message)
    Deprecated.
    Use HttpUtil.is100ContinueExpected(HttpMessage) instead.
    static boolean
    isContentLengthSet(HttpMessage m)
    Deprecated.
    Use HttpUtil.isContentLengthSet(HttpMessage) instead.
    abstract boolean
    isEmpty()
    Checks if no header exists.
    static boolean
    isKeepAlive(HttpMessage message)
    Deprecated.
    Use HttpUtil.isKeepAlive(HttpMessage) instead.
    static boolean
    isTransferEncodingChunked(HttpMessage message)
    Deprecated.
    Use HttpUtil.isTransferEncodingChunked(HttpMessage) instead.
    abstract Iterator<Map.Entry<String,String>>
    iterator()
    Deprecated.
    It is preferred to use iteratorCharSequence() unless you need String.
    final Iterator<Map.Entry<String,String>>
    iteratorAsString()
    Iterator that converts each Map.Entry's key and value to a String.
    abstract Iterator<Map.Entry<CharSequence, CharSequence>>
    iteratorCharSequence()
     
    abstract Set<String>
    names()
    Returns a new Set that contains the names of all headers in this object.
    static CharSequence
    newEntity(String name)
    Deprecated.
    Use AsciiString instead.
    HttpHeaders
    remove(CharSequence name)
    Removes the header with the specified name.
    abstract HttpHeaders
    remove(String name)
     
    static void
    removeHeader(HttpMessage message, CharSequence name)
    Deprecated.
    Use remove(CharSequence) instead.
    static void
    removeHeader(HttpMessage message, String name)
    Deprecated.
    Use remove(CharSequence) instead.
    static void
    removeTransferEncodingChunked(HttpMessage m)
    Deprecated.
    Use HttpUtil.setTransferEncodingChunked(HttpMessage, boolean) instead.
    HttpHeaders
    set(HttpHeaders headers)
    Cleans the current header entries and copies all header entries of the specified headers.
    HttpHeaders
    set(CharSequence name, Iterable<?> values)
    Sets a header with the specified name and values.
    HttpHeaders
    set(CharSequence name, Object value)
    Sets a header with the specified name and value.
    abstract HttpHeaders
    set(String name, Iterable<?> values)
     
    abstract HttpHeaders
    set(String name, Object value)
     
    static void
    set100ContinueExpected(HttpMessage message)
    Deprecated.
    Use HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead.
    static void
    set100ContinueExpected(HttpMessage message, boolean set)
    Deprecated.
    Use HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead.
    HttpHeaders
    setAll(HttpHeaders headers)
    Retains all current headers but calls set(String, Object) for each entry in headers
    static void
    setContentLength(HttpMessage message, long length)
    Deprecated.
    Use HttpUtil.setContentLength(HttpMessage, long) instead.
    static void
    setDate(HttpMessage message, Date value)
    Deprecated.
    Use set(CharSequence, Object) instead.
    static void
    setDateHeader(HttpMessage message, CharSequence name, Iterable<Date> values)
    Deprecated.
    Use set(CharSequence, Iterable) instead.
    static void
    setDateHeader(HttpMessage message, CharSequence name, Date value)
    Deprecated.
    Use set(CharSequence, Object) instead.
    static void
    setDateHeader(HttpMessage message, String name, Iterable<Date> values)
    Deprecated.
    Use set(CharSequence, Iterable) instead.
    static void
    setDateHeader(HttpMessage message, String name, Date value)
    Deprecated.
    Use set(CharSequence, Object) instead.
    static void
    setHeader(HttpMessage message, CharSequence name, Iterable<?> values)
    Deprecated.
    Use set(CharSequence, Iterable) instead.
    static void
    setHeader(HttpMessage message, CharSequence name, Object value)
    Deprecated.
    Use set(CharSequence, Object) instead.
    static void
    setHeader(HttpMessage message, String name, Iterable<?> values)
    Deprecated.
    Use set(CharSequence, Iterable) instead.
    static void
    setHeader(HttpMessage message, String name, Object value)
    Deprecated.
    Use set(CharSequence, Object) instead.
    static void
    setHost(HttpMessage message, CharSequence value)
    Deprecated.
    Use set(CharSequence, Object) instead.
    static void
    setHost(HttpMessage message, String value)
    Deprecated.
    Use set(CharSequence, Object) instead.
    abstract HttpHeaders
    setInt(CharSequence name, int value)
    Set the name to value.
    static void
    setIntHeader(HttpMessage message, CharSequence name, int value)
    Deprecated.
    Use setInt(CharSequence, int) instead.
    static void
    setIntHeader(HttpMessage message, CharSequence name, Iterable<Integer> values)
    Deprecated.
    Use set(CharSequence, Iterable) instead.
    static void
    setIntHeader(HttpMessage message, String name, int value)
    Deprecated.
    Use setInt(CharSequence, int) instead.
    static void
    setIntHeader(HttpMessage message, String name, Iterable<Integer> values)
    Deprecated.
    Use set(CharSequence, Iterable) instead.
    static void
    setKeepAlive(HttpMessage message, boolean keepAlive)
    Deprecated.
    Use HttpUtil.setKeepAlive(HttpMessage, boolean) instead.
    abstract HttpHeaders
    setShort(CharSequence name, short value)
    Set the name to value.
    static void
    setTransferEncodingChunked(HttpMessage m)
    Deprecated.
    Use HttpUtil.setTransferEncodingChunked(HttpMessage, boolean) instead.
    abstract int
    size()
    Returns the number of headers in this object.
    String
    toString()
     
    Iterator<? extends CharSequence>
    valueCharSequenceIterator(CharSequence name)
    Equivalent to getAll(String) but it is possible that no intermediate list is generated.
    Iterator<String>
    valueStringIterator(CharSequence name)
    Equivalent to getAll(String) but it is possible that no intermediate list is generated.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface Iterable

    forEach, spliterator
  • Field Details

    • EMPTY_HEADERS

      @Deprecated public static final HttpHeaders EMPTY_HEADERS
      Deprecated.
      Use EmptyHttpHeaders.INSTANCE.

      The instance is instantiated here to break the cyclic static initialization between EmptyHttpHeaders and HttpHeaders. The issue is that if someone accesses EmptyHttpHeaders.INSTANCE before EMPTY_HEADERS then EMPTY_HEADERS will be null.

  • Constructor Details

    • HttpHeaders

      protected HttpHeaders()
  • Method Details

    • isKeepAlive

      @Deprecated public static boolean isKeepAlive(HttpMessage message)
      Deprecated.
      Use HttpUtil.isKeepAlive(HttpMessage) instead. Returns true if and only if the connection can remain open and thus 'kept alive'. This methods respects the value of the "Connection" header first and then the return value of HttpVersion.isKeepAliveDefault().
    • setKeepAlive

      @Deprecated public static void setKeepAlive(HttpMessage message, boolean keepAlive)
      Deprecated.
      Use HttpUtil.setKeepAlive(HttpMessage, boolean) instead. Sets the value of the "Connection" header depending on the protocol version of the specified message. This getMethod sets or removes the "Connection" header depending on what the default keep alive mode of the message's protocol version is, as specified by HttpVersion.isKeepAliveDefault().
      • If the connection is kept alive by default:
        • set to "close" if keepAlive is false.
        • remove otherwise.
      • If the connection is closed by default:
        • set to "keep-alive" if keepAlive is true.
        • remove otherwise.
    • getHeader

      @Deprecated public static String getHeader(HttpMessage message, String name)
      Deprecated.
      Use get(CharSequence) instead.
    • getHeader

      @Deprecated public static String getHeader(HttpMessage message, CharSequence name)
      Deprecated.
      Use get(CharSequence) instead. 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.
      Returns:
      the header value or null if there is no such header
    • getHeader

      @Deprecated public static String getHeader(HttpMessage message, String name, String defaultValue)
      Deprecated.
      Use get(CharSequence, String) instead.
      See Also:
      • getHeader(HttpMessage, CharSequence, String)
    • getHeader

      @Deprecated public static String getHeader(HttpMessage message, CharSequence name, String defaultValue)
      Deprecated.
      Use get(CharSequence, String) instead. 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.
      Returns:
      the header value or the defaultValue if there is no such header
    • setHeader

      @Deprecated public static void setHeader(HttpMessage message, String name, Object value)
      Deprecated.
      Use set(CharSequence, Object) instead.
      See Also:
      • setHeader(HttpMessage, CharSequence, Object)
    • setHeader

      @Deprecated public static void setHeader(HttpMessage message, CharSequence name, Object value)
      Deprecated.
      Use set(CharSequence, Object) instead. 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. If the specified value is not a String, it is converted into a String by Object.toString(), except for Date and Calendar which are formatted to the date format defined in RFC2616.
    • setHeader

      @Deprecated public static void setHeader(HttpMessage message, String name, Iterable<?> values)
      Deprecated.
      Use set(CharSequence, Iterable) instead.
      See Also:
      • setHeader(HttpMessage, CharSequence, Iterable)
    • setHeader

      @Deprecated public static void setHeader(HttpMessage message, CharSequence name, Iterable<?> values)
      Deprecated.
      Use set(CharSequence, Iterable) instead. 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. This getMethod can be represented approximately as the following code:
      removeHeader(message, name);
      for (Object v: values) {
          if (v == null) {
              break;
          }
          addHeader(message, name, v);
      }
      
    • addHeader

      @Deprecated public static void addHeader(HttpMessage message, String name, Object value)
      Deprecated.
      Use add(CharSequence, Object) instead.
      See Also:
      • addHeader(HttpMessage, CharSequence, Object)
    • addHeader

      @Deprecated public static void addHeader(HttpMessage message, CharSequence name, Object value)
      Deprecated.
      Use add(CharSequence, Object) instead. Adds a new header with the specified name and value. If the specified value is not a String, it is converted into a String by Object.toString(), except for Date and Calendar which are formatted to the date format defined in RFC2616.
    • removeHeader

      @Deprecated public static void removeHeader(HttpMessage message, String name)
      Deprecated.
      Use remove(CharSequence) instead.
      See Also:
      • removeHeader(HttpMessage, CharSequence)
    • removeHeader

      @Deprecated public static void removeHeader(HttpMessage message, CharSequence name)
      Deprecated.
      Use remove(CharSequence) instead. Removes the header with the specified name.
    • clearHeaders

      @Deprecated public static void clearHeaders(HttpMessage message)
      Deprecated.
      Use clear() instead. Removes all headers from the specified message.
    • getIntHeader

      @Deprecated public static int getIntHeader(HttpMessage message, String name)
      Deprecated.
      Use getInt(CharSequence) instead.
      See Also:
      • getIntHeader(HttpMessage, CharSequence)
    • getIntHeader

      @Deprecated public static int getIntHeader(HttpMessage message, CharSequence name)
      Deprecated.
      Use getInt(CharSequence) instead. 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.
      Returns:
      the header value
      Throws:
      NumberFormatException - if there is no such header or the header value is not a number
    • getIntHeader

      @Deprecated public static int getIntHeader(HttpMessage message, String name, int defaultValue)
      Deprecated.
      Use getInt(CharSequence, int) instead.
      See Also:
      • getIntHeader(HttpMessage, CharSequence, int)
    • getIntHeader

      @Deprecated public static int getIntHeader(HttpMessage message, CharSequence name, int defaultValue)
      Deprecated.
      Use getInt(CharSequence, int) instead. 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.
      Returns:
      the header value or the defaultValue if there is no such header or the header value is not a number
    • setIntHeader

      @Deprecated public static void setIntHeader(HttpMessage message, String name, int value)
      Deprecated.
      Use setInt(CharSequence, int) instead.
      See Also:
      • setIntHeader(HttpMessage, CharSequence, int)
    • setIntHeader

      @Deprecated public static void setIntHeader(HttpMessage message, CharSequence name, int value)
      Deprecated.
      Use setInt(CharSequence, int) instead. 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.
    • setIntHeader

      @Deprecated public static void setIntHeader(HttpMessage message, String name, Iterable<Integer> values)
      Deprecated.
      Use set(CharSequence, Iterable) instead.
      See Also:
      • setIntHeader(HttpMessage, CharSequence, Iterable)
    • setIntHeader

      @Deprecated public static void setIntHeader(HttpMessage message, CharSequence name, Iterable<Integer> values)
      Deprecated.
      Use set(CharSequence, Iterable) instead. 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.
    • addIntHeader

      @Deprecated public static void addIntHeader(HttpMessage message, String name, int value)
      Deprecated.
      Use add(CharSequence, Iterable) instead.
      See Also:
      • addIntHeader(HttpMessage, CharSequence, int)
    • addIntHeader

      @Deprecated public static void addIntHeader(HttpMessage message, CharSequence name, int value)
      Deprecated.
      Use addInt(CharSequence, int) instead. Adds a new integer header with the specified name and value.
    • getDateHeader

      @Deprecated public static Date getDateHeader(HttpMessage message, String name) throws ParseException
      Deprecated.
      Use getTimeMillis(CharSequence) instead.
      Throws:
      ParseException
      See Also:
      • getDateHeader(HttpMessage, CharSequence)
    • getDateHeader

      @Deprecated public static Date getDateHeader(HttpMessage message, CharSequence name) throws ParseException
      Deprecated.
      Use getTimeMillis(CharSequence) instead. 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.
      Returns:
      the header value
      Throws:
      ParseException - if there is no such header or the header value is not a formatted date
    • getDateHeader

      @Deprecated public static Date getDateHeader(HttpMessage message, String name, Date defaultValue)
      Deprecated.
      Use getTimeMillis(CharSequence, long) instead.
      See Also:
      • getDateHeader(HttpMessage, CharSequence, Date)
    • getDateHeader

      @Deprecated public static Date getDateHeader(HttpMessage message, CharSequence name, Date defaultValue)
      Deprecated.
      Use getTimeMillis(CharSequence, long) instead. 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.
      Returns:
      the header value or the defaultValue if there is no such header or the header value is not a formatted date
    • setDateHeader

      @Deprecated public static void setDateHeader(HttpMessage message, String name, Date value)
      Deprecated.
      Use set(CharSequence, Object) instead.
      See Also:
      • setDateHeader(HttpMessage, CharSequence, Date)
    • setDateHeader

      @Deprecated public static void setDateHeader(HttpMessage message, CharSequence name, Date value)
      Deprecated.
      Use set(CharSequence, Object) instead. 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 RFC2616
    • setDateHeader

      @Deprecated public static void setDateHeader(HttpMessage message, String name, Iterable<Date> values)
      Deprecated.
      Use set(CharSequence, Iterable) instead.
      See Also:
      • setDateHeader(HttpMessage, CharSequence, Iterable)
    • setDateHeader

      @Deprecated public static void setDateHeader(HttpMessage message, CharSequence name, Iterable<Date> values)
      Deprecated.
      Use set(CharSequence, Iterable) instead. 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 RFC2616
    • addDateHeader

      @Deprecated public static void addDateHeader(HttpMessage message, String name, Date value)
      Deprecated.
      Use add(CharSequence, Object) instead.
      See Also:
      • addDateHeader(HttpMessage, CharSequence, Date)
    • addDateHeader

      @Deprecated public static void addDateHeader(HttpMessage message, CharSequence name, Date value)
      Deprecated.
      Use add(CharSequence, Object) instead. Adds a new date header with the specified name and value. The specified value is formatted as defined in RFC2616
    • getContentLength

      @Deprecated public static long getContentLength(HttpMessage message)
      Deprecated.
      Use HttpUtil.getContentLength(HttpMessage) instead. Returns the length of the content. Please note that this value is not retrieved from ByteBufHolder.content() but from the "Content-Length" header, and thus they are independent from each other.
      Returns:
      the content length
      Throws:
      NumberFormatException - if the message does not have the "Content-Length" header or its value is not a number
    • getContentLength

      @Deprecated public static long getContentLength(HttpMessage message, long defaultValue)
      Deprecated.
      Use HttpUtil.getContentLength(HttpMessage, long) instead. Returns the length of the content. Please note that this value is not retrieved from ByteBufHolder.content() but from the "Content-Length" header, and thus they are independent from each other.
      Returns:
      the content length or defaultValue if this message does not have the "Content-Length" header or its value is not a number
    • setContentLength

      @Deprecated public static void setContentLength(HttpMessage message, long length)
      Deprecated.
      Use HttpUtil.setContentLength(HttpMessage, long) instead.
    • getHost

      @Deprecated public static String getHost(HttpMessage message)
      Deprecated.
      Use get(CharSequence) instead. Returns the value of the "Host" header.
    • getHost

      @Deprecated public static String getHost(HttpMessage message, String defaultValue)
      Deprecated.
      Use get(CharSequence, String) instead. Returns the value of the "Host" header. If there is no such header, the defaultValue is returned.
    • setHost

      @Deprecated public static void setHost(HttpMessage message, String value)
      Deprecated.
      Use set(CharSequence, Object) instead.
      See Also:
      • setHost(HttpMessage, CharSequence)
    • setHost

      @Deprecated public static void setHost(HttpMessage message, CharSequence value)
      Deprecated.
      Use set(CharSequence, Object) instead. Sets the "Host" header.
    • getDate

      @Deprecated public static Date getDate(HttpMessage message) throws ParseException
      Deprecated.
      Use getTimeMillis(CharSequence) instead. Returns the value of the "Date" header.
      Throws:
      ParseException - if there is no such header or the header value is not a formatted date
    • getDate

      @Deprecated public static Date getDate(HttpMessage message, Date defaultValue)
      Deprecated.
      Use getTimeMillis(CharSequence, long) instead. Returns the value of the "Date" header. If there is no such header or the header is not a formatted date, the defaultValue is returned.
    • setDate

      @Deprecated public static void setDate(HttpMessage message, Date value)
      Deprecated.
      Use set(CharSequence, Object) instead. Sets the "Date" header.
    • is100ContinueExpected

      @Deprecated public static boolean is100ContinueExpected(HttpMessage message)
      Deprecated.
      Use HttpUtil.is100ContinueExpected(HttpMessage) instead. Returns true if and only if the specified message contains the "Expect: 100-continue" header.
    • set100ContinueExpected

      @Deprecated public static void set100ContinueExpected(HttpMessage message)
      Deprecated.
      Use HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead. Sets the "Expect: 100-continue" header to the specified message. If there is any existing "Expect" header, they are replaced with the new one.
    • set100ContinueExpected

      @Deprecated public static void set100ContinueExpected(HttpMessage message, boolean set)
      Deprecated.
      Use HttpUtil.set100ContinueExpected(HttpMessage, boolean) instead. Sets or removes the "Expect: 100-continue" header to / from the specified message. If set is true, the "Expect: 100-continue" header is set and all other previous "Expect" headers are removed. Otherwise, all "Expect" headers are removed completely.
    • isTransferEncodingChunked

      @Deprecated public static boolean isTransferEncodingChunked(HttpMessage message)
      Deprecated.
      Use HttpUtil.isTransferEncodingChunked(HttpMessage) instead. Checks to see if the transfer encoding in a specified HttpMessage is chunked
      Parameters:
      message - The message to check
      Returns:
      True if transfer encoding is chunked, otherwise false
    • removeTransferEncodingChunked

      @Deprecated public static void removeTransferEncodingChunked(HttpMessage m)
      Deprecated.
      Use HttpUtil.setTransferEncodingChunked(HttpMessage, boolean) instead.
    • setTransferEncodingChunked

      @Deprecated public static void setTransferEncodingChunked(HttpMessage m)
      Deprecated.
      Use HttpUtil.setTransferEncodingChunked(HttpMessage, boolean) instead.
    • isContentLengthSet

      @Deprecated public static boolean isContentLengthSet(HttpMessage m)
      Deprecated.
      Use HttpUtil.isContentLengthSet(HttpMessage) instead.
    • equalsIgnoreCase

      @Deprecated public static boolean equalsIgnoreCase(CharSequence name1, CharSequence name2)
      Deprecated.
      Use AsciiString.contentEqualsIgnoreCase(CharSequence, CharSequence) instead.
    • encodeAscii

      @Deprecated public static void encodeAscii(CharSequence seq, ByteBuf buf)
      Deprecated.
    • newEntity

      @Deprecated public static CharSequence newEntity(String name)
      Deprecated.
      Use AsciiString instead.

      Create a new CharSequence which is optimized for reuse as HttpHeaders name or value. So if you have a Header name or value that you want to reuse you should make use of this.

    • get

      public abstract String get(String name)
      See Also:
      • get(CharSequence)
    • get

      public String get(CharSequence name)
      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.
      Parameters:
      name - The name of the header to search
      Returns:
      The first header value or null if there is no such header
      See Also:
      • getAsString(CharSequence)
    • get

      public String get(CharSequence name, String defaultValue)
      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.
      Parameters:
      name - The name of the header to search
      Returns:
      The first header value or defaultValue if there is no such header
    • getInt

      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.
      Parameters:
      name - the name of the header to search
      Returns:
      the first header value if the header is found and its value is an integer. null if there's no such header or its value is not an integer.
    • getInt

      public abstract int getInt(CharSequence name, int defaultValue)
      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.
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the first header value if the header is found and its value is an integer. defaultValue if there's no such header or its value is not an integer.
    • getShort

      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.
      Parameters:
      name - the name of the header to search
      Returns:
      the first header value if the header is found and its value is a short. null if there's no such header or its value is not a short.
    • getShort

      public abstract short getShort(CharSequence name, short defaultValue)
      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.
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the first header value if the header is found and its value is a short. defaultValue if there's no such header or its value is not a short.
    • getTimeMillis

      public abstract Long getTimeMillis(CharSequence name)
      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.
      Parameters:
      name - the name of the header to search
      Returns:
      the first header value if the header is found and its value is a date. null if there's no such header or its value is not a date.
    • getTimeMillis

      public abstract long getTimeMillis(CharSequence name, long defaultValue)
      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.
      Parameters:
      name - the name of the header to search
      defaultValue - the default value
      Returns:
      the first header value if the header is found and its value is a date. defaultValue if there's no such header or its value is not a date.
    • getAll

      public abstract List<String> getAll(String name)
      See Also:
      • getAll(CharSequence)
    • getAll

      public List<String> getAll(CharSequence name)
      Returns the values of headers with the specified name
      Parameters:
      name - The name of the headers to search
      Returns:
      A List of header values which will be empty if no values are found
      See Also:
      • getAllAsString(CharSequence)
    • entries

      public abstract List<Map.Entry<String,String>> entries()
      Returns a new List 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 iterator() instead, which has much less overhead.
      See Also:
      • iteratorCharSequence()
    • contains

      public abstract boolean contains(String name)
      See Also:
      • contains(CharSequence)
    • iterator

      @Deprecated public abstract Iterator<Map.Entry<String,String>> iterator()
      Deprecated.
      It is preferred to use iteratorCharSequence() unless you need String. If String is required then use iteratorAsString().
      Specified by:
      iterator in interface Iterable<Map.Entry<String,String>>
    • iteratorCharSequence

      public abstract Iterator<Map.Entry<CharSequence, CharSequence>> iteratorCharSequence()
      Returns:
      Iterator over the name/value header pairs.
    • valueStringIterator

      public Iterator<String> valueStringIterator(CharSequence name)
      Equivalent to getAll(String) but it is possible that no intermediate list is generated.
      Parameters:
      name - the name of the header to retrieve
      Returns:
      an Iterator of header values corresponding to name.
    • valueCharSequenceIterator

      public Iterator<? extends CharSequence> valueCharSequenceIterator(CharSequence name)
      Equivalent to getAll(String) but it is possible that no intermediate list is generated.
      Parameters:
      name - the name of the header to retrieve
      Returns:
      an Iterator of header values corresponding to name.
    • contains

      public boolean contains(CharSequence name)
      Checks to see if there is a header with the specified name
      Parameters:
      name - The name of the header to search for
      Returns:
      True if at least one header is found
    • isEmpty

      public abstract boolean isEmpty()
      Checks if no header exists.
    • size

      public abstract int size()
      Returns the number of headers in this object.
    • names

      public abstract Set<String> names()
      Returns a new Set 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 iterator() instead, which has much less overhead.
    • add

      public abstract HttpHeaders add(String name, Object value)
      See Also:
      • add(CharSequence, Object)
    • add

      public HttpHeaders add(CharSequence name, Object value)
      Adds a new header with the specified name and value. If the specified value is not a String, it is converted into a String by Object.toString(), except in the cases of Date and Calendar, which are formatted to the date format defined in RFC2616.
      Parameters:
      name - The name of the header being added
      value - The value of the header being added
      Returns:
      this
    • add

      public abstract HttpHeaders add(String name, Iterable<?> values)
      See Also:
      • add(CharSequence, Iterable)
    • add

      public HttpHeaders add(CharSequence name, Iterable<?> values)
      Adds 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);
      }
      
      Parameters:
      name - The name of the headers being set
      values - The values of the headers being set
      Returns:
      this
    • add

      public HttpHeaders add(HttpHeaders headers)
      Adds all header entries of the specified headers.
      Returns:
      this
    • addInt

      public abstract HttpHeaders addInt(CharSequence name, int value)
      Add the name to value.
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • addShort

      public abstract HttpHeaders addShort(CharSequence name, short value)
      Add the name to value.
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • set

      public abstract HttpHeaders set(String name, Object value)
      See Also:
      • set(CharSequence, Object)
    • set

      public HttpHeaders set(CharSequence name, Object value)
      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 String, it is converted into a String by Object.toString(), except for Date and Calendar, which are formatted to the date format defined in RFC2616.
      Parameters:
      name - The name of the header being set
      value - The value of the header being set
      Returns:
      this
    • set

      public abstract HttpHeaders set(String name, Iterable<?> values)
      See Also:
      • set(CharSequence, Iterable)
    • set

      public HttpHeaders set(CharSequence name, Iterable<?> values)
      Sets 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);
      }
      
      Parameters:
      name - The name of the headers being set
      values - The values of the headers being set
      Returns:
      this
    • set

      public HttpHeaders set(HttpHeaders headers)
      Cleans the current header entries and copies all header entries of the specified headers.
      Returns:
      this
    • setAll

      public HttpHeaders setAll(HttpHeaders headers)
      Retains all current headers but calls set(String, Object) for each entry in headers
      Parameters:
      headers - The headers used to set(String, Object) values in this instance
      Returns:
      this
    • setInt

      public abstract HttpHeaders setInt(CharSequence name, int value)
      Set the name to value. This will remove all previous values associated with name.
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • setShort

      public abstract HttpHeaders setShort(CharSequence name, short value)
      Set the name to value. This will remove all previous values associated with name.
      Parameters:
      name - The name to modify
      value - The value
      Returns:
      this
    • remove

      public abstract HttpHeaders remove(String name)
      See Also:
      • remove(CharSequence)
    • remove

      public HttpHeaders remove(CharSequence name)
      Removes the header with the specified name.
      Parameters:
      name - The name of the header to remove
      Returns:
      this
    • clear

      public abstract HttpHeaders clear()
      Removes all headers from this HttpMessage.
      Returns:
      this
    • contains

      public boolean contains(String name, String value, boolean ignoreCase)
      See Also:
      • contains(CharSequence, CharSequence, boolean)
    • containsValue

      public boolean containsValue(CharSequence name, CharSequence value, boolean ignoreCase)
      Returns true 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.

      Parameters:
      name - the name of the header to find
      value - the value of the header to find
      ignoreCase - true then a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
    • getAsString

      public final String getAsString(CharSequence name)
      Headers.get(Object) and convert the result to a String.
      Parameters:
      name - the name of the header to retrieve
      Returns:
      the first header value if the header is found. null if there's no such header.
    • getAllAsString

      public final List<String> getAllAsString(CharSequence name)
      Headers.getAll(Object) and convert each element of List to a String.
      Parameters:
      name - the name of the header to retrieve
      Returns:
      a List of header values or an empty List if no values are found.
    • iteratorAsString

      public final Iterator<Map.Entry<String,String>> iteratorAsString()
      Iterator that converts each Map.Entry's key and value to a String.
    • contains

      public boolean contains(CharSequence name, CharSequence value, boolean ignoreCase)
      Returns true if a header with the name and value exists, false otherwise.

      If ignoreCase is true then a case insensitive compare is done on the value.

      Parameters:
      name - the name of the header to find
      value - the value of the header to find
      ignoreCase - true then a case insensitive compare is run to compare values. otherwise a case sensitive compare is run to compare values.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • copy

      public HttpHeaders copy()
      Returns a deep copy of the passed in HttpHeaders.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.