Class HttpVersion

  • All Implemented Interfaces:
    java.lang.Comparable<HttpVersion>

    public class HttpVersion
    extends java.lang.Object
    implements java.lang.Comparable<HttpVersion>
    The version of HTTP or its derived protocols, such as RTSP and ICAP.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        HttpVersion​(java.lang.String text, boolean keepAliveDefault)
      Creates a new HTTP version with the specified version string.
      (package private) HttpVersion​(java.lang.String text, boolean strict, boolean keepAliveDefault)  
        HttpVersion​(java.lang.String protocolName, int majorVersion, int minorVersion, boolean keepAliveDefault)
      Creates a new HTTP version with the specified protocol name and version numbers.
      private HttpVersion​(java.lang.String protocolName, int majorVersion, int minorVersion, boolean keepAliveDefault, boolean bytes)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(HttpVersion o)  
      (package private) void encode​(ByteBuf buf)  
      boolean equals​(java.lang.Object o)  
      int hashCode()  
      boolean isKeepAliveDefault()
      Returns true if and only if the connection is kept alive unless the "Connection" header is set to "close" explicitly.
      int majorVersion()
      Returns the name of the protocol such as 1 in "HTTP/1.0".
      int minorVersion()
      Returns the name of the protocol such as 0 in "HTTP/1.0".
      java.lang.String protocolName()
      Returns the name of the protocol such as "HTTP" in "HTTP/1.0".
      java.lang.String text()
      Returns the full protocol version text such as "HTTP/1.0".
      private static int toDecimal​(int value)  
      java.lang.String toString()
      Returns the full protocol version text such as "HTTP/1.0".
      static HttpVersion valueOf​(java.lang.String text)
      Returns an existing or new HttpVersion instance which matches to the specified protocol version string.
      (package private) static HttpVersion valueOf​(java.lang.String text, boolean strict)  
      private static HttpVersion version0​(java.lang.String text)  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • VERSION_PATTERN

        private static final java.util.regex.Pattern VERSION_PATTERN
      • HTTP_1_0

        public static final HttpVersion HTTP_1_0
        HTTP/1.0
      • HTTP_1_1

        public static final HttpVersion HTTP_1_1
        HTTP/1.1
      • protocolName

        private final java.lang.String protocolName
      • majorVersion

        private final int majorVersion
      • minorVersion

        private final int minorVersion
      • text

        private final java.lang.String text
      • keepAliveDefault

        private final boolean keepAliveDefault
      • bytes

        private final byte[] bytes
    • Constructor Detail

      • HttpVersion

        public HttpVersion​(java.lang.String text,
                           boolean keepAliveDefault)
        Creates a new HTTP version with the specified version string. You will not need to create a new instance unless you are implementing a protocol derived from HTTP, such as RTSP and ICAP.
        Parameters:
        keepAliveDefault - true if and only if the connection is kept alive unless the "Connection" header is set to "close" explicitly.
      • HttpVersion

        HttpVersion​(java.lang.String text,
                    boolean strict,
                    boolean keepAliveDefault)
      • HttpVersion

        public HttpVersion​(java.lang.String protocolName,
                           int majorVersion,
                           int minorVersion,
                           boolean keepAliveDefault)
        Creates a new HTTP version with the specified protocol name and version numbers. You will not need to create a new instance unless you are implementing a protocol derived from HTTP, such as RTSP and ICAP
        Parameters:
        keepAliveDefault - true if and only if the connection is kept alive unless the "Connection" header is set to "close" explicitly.
      • HttpVersion

        private HttpVersion​(java.lang.String protocolName,
                            int majorVersion,
                            int minorVersion,
                            boolean keepAliveDefault,
                            boolean bytes)
    • Method Detail

      • valueOf

        public static HttpVersion valueOf​(java.lang.String text)
        Returns an existing or new HttpVersion instance which matches to the specified protocol version string. If the specified text is equal to "HTTP/1.0", HTTP_1_0 will be returned. If the specified text is equal to "HTTP/1.1", HTTP_1_1 will be returned. Otherwise, a new HttpVersion instance will be returned.
      • valueOf

        static HttpVersion valueOf​(java.lang.String text,
                                   boolean strict)
      • version0

        private static HttpVersion version0​(java.lang.String text)
      • toDecimal

        private static int toDecimal​(int value)
      • protocolName

        public java.lang.String protocolName()
        Returns the name of the protocol such as "HTTP" in "HTTP/1.0".
      • majorVersion

        public int majorVersion()
        Returns the name of the protocol such as 1 in "HTTP/1.0".
      • minorVersion

        public int minorVersion()
        Returns the name of the protocol such as 0 in "HTTP/1.0".
      • text

        public java.lang.String text()
        Returns the full protocol version text such as "HTTP/1.0".
      • isKeepAliveDefault

        public boolean isKeepAliveDefault()
        Returns true if and only if the connection is kept alive unless the "Connection" header is set to "close" explicitly.
      • toString

        public java.lang.String toString()
        Returns the full protocol version text such as "HTTP/1.0".
        Overrides:
        toString in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • compareTo

        public int compareTo​(HttpVersion o)
        Specified by:
        compareTo in interface java.lang.Comparable<HttpVersion>
      • encode

        void encode​(ByteBuf buf)