Class PreEncodedHttpField

java.lang.Object
org.eclipse.jetty.http.HttpField
org.eclipse.jetty.http.PreEncodedHttpField
Direct Known Subclasses:
ResponseHttpFields.PersistentPreEncodedHttpField

public class PreEncodedHttpField extends HttpField
Pre encoded HttpField.

An HttpField that will be cached and used many times can be created as a PreEncodedHttpField, which will use the HttpFieldPreEncoder instances discovered by the ServiceLoader to pre-encode the header for each version of HTTP in use. This will save garbage and CPU each time the field is encoded into a response.

  • Constructor Details

    • PreEncodedHttpField

      public PreEncodedHttpField(HttpHeader header, String name, String value)
    • PreEncodedHttpField

      public PreEncodedHttpField(HttpHeader header, String value)
    • PreEncodedHttpField

      public PreEncodedHttpField(HttpHeader header, long value)
    • PreEncodedHttpField

      public PreEncodedHttpField(String name, String value)
    • PreEncodedHttpField

      public PreEncodedHttpField(String name, long value)
  • Method Details

    • putTo

      public void putTo(ByteBuffer bufferInFillMode, HttpVersion version)
    • getEncodedLength

      public int getEncodedLength(HttpVersion version)
    • contains

      public boolean contains(String search)
      Description copied from class: HttpField

      Returns whether this field value, possibly multi-valued, contains the specified search string, case-insensitively.

      Only values, and not parameters, are compared with the search string.

      Overrides:
      contains in class HttpField
      Parameters:
      search - the string to search for
      Returns:
      whether this field value, possibly multi-valued, contains the specified search string
    • getIntValue

      public int getIntValue()
      Overrides:
      getIntValue in class HttpField
      Returns:
      the value of this field as an int
    • getLongValue

      public long getLongValue()
      Overrides:
      getLongValue in class HttpField
      Returns:
      the value of this field as an long