Class AbstractMessageParser<T extends HttpMessage>

    • Constructor Detail

      • AbstractMessageParser

        public AbstractMessageParser​(LineParser lineParser,
                                     Http1Config http1Config)
        Creates new instance of AbstractMessageParser.
        Parameters:
        lineParser - the line parser. If null LazyLineParser.INSTANCE will be used.
        http1Config - the message http1Config. If null Http1Config.DEFAULT will be used.
        Since:
        4.3
    • Method Detail

      • parseHeaders

        public static Header[] parseHeaders​(SessionInputBuffer inBuffer,
                                            java.io.InputStream inputStream,
                                            int maxHeaderCount,
                                            int maxLineLen,
                                            LineParser lineParser)
                                     throws HttpException,
                                            java.io.IOException
        Parses HTTP headers from the data receiver stream according to the generic format as specified by the HTTP/1.1 protocol specification.
        Parameters:
        inBuffer - Session input buffer
        inputStream - Input stream
        maxHeaderCount - maximum number of headers allowed. If the number of headers received from the data stream exceeds maxCount value, an IOException will be thrown. Setting this parameter to a negative value or zero will disable the check.
        maxLineLen - maximum number of characters for a header line, including the continuation lines. Setting this parameter to a negative value or zero will disable the check.
        lineParser - the line parser. If null LazyLineParser.INSTANCE will be used
        Returns:
        array of HTTP headers
        Throws:
        java.io.IOException - in case of an I/O error
        HttpException - in case of HTTP protocol violation
      • parseHeaders

        public static Header[] parseHeaders​(SessionInputBuffer inBuffer,
                                            java.io.InputStream inputStream,
                                            int maxHeaderCount,
                                            int maxLineLen,
                                            LineParser parser,
                                            java.util.List<CharArrayBuffer> headerLines)
                                     throws HttpException,
                                            java.io.IOException
        Parses HTTP headers from the data receiver stream according to the generic format as specified by the HTTP/1.1 protocol specification.
        Parameters:
        inBuffer - Session input buffer
        inputStream - Input stream
        maxHeaderCount - maximum number of headers allowed. If the number of headers received from the data stream exceeds maxCount value, an IOException will be thrown. Setting this parameter to a negative value or zero will disable the check.
        maxLineLen - maximum number of characters for a header line, including the continuation lines. Setting this parameter to a negative value or zero will disable the check.
        parser - line parser to use.
        headerLines - List of header lines. This list will be used to store intermediate results. This makes it possible to resume parsing of headers in case of a InterruptedIOException.
        Returns:
        array of HTTP headers
        Throws:
        java.io.IOException - in case of an I/O error
        HttpException - in case of HTTP protocol violation
        Since:
        4.1
      • createMessage

        protected abstract T createMessage​(CharArrayBuffer buffer)
                                    throws java.io.IOException,
                                           HttpException
        Subclasses must override this method to generate an instance of HttpMessage based on the initial input from the session buffer.

        Usually this method is expected to read just the very first line or the very first valid from the data stream and based on the input generate an appropriate instance of HttpMessage.

        Parameters:
        buffer - the session input buffer.
        Returns:
        HTTP message based on the input from the session buffer.
        Throws:
        java.io.IOException - in case of an I/O error.
        HttpException - in case of HTTP protocol violation.
        Since:
        5.0
      • createConnectionClosedException

        @Deprecated
        protected java.io.IOException createConnectionClosedException()
        Deprecated.
        do not use.
        Subclasses must override this method to generate an appropriate exception in case of unexpected connection termination by the peer endpoint.
        Since:
        5.0
      • parse

        public T parse​(SessionInputBuffer buffer,
                       java.io.InputStream inputStream)
                throws java.io.IOException,
                       HttpException
        Description copied from interface: HttpMessageParser
        Generates an instance of MessageHeaders from the given input stream..
        Specified by:
        parse in interface HttpMessageParser<T extends HttpMessage>
        Parameters:
        buffer - Session input buffer
        inputStream - Input stream
        Returns:
        HTTP message head or null if the input stream has been closed by the opposite endpoint.
        Throws:
        java.io.IOException - in case of an I/O error
        HttpException - in case of HTTP protocol violation