Package kilim.http

Class HttpRequest


  • public class HttpRequest
    extends HttpMsg
    This object encapsulates a bytebuffer (via HttpMsg). HttpRequestParser creates an instance of this object, but only converts a few of the important fields into Strings; the rest are maintained as ranges (offset + length) in the bytebuffer. Use getHeader(String) to get the appropriate field.
    • Field Detail

      • method

        public java.lang.String method
        The original header. All string variables that pertain to the message's header are either subsequences of this header, or interned (all known keywords).
      • uriPath

        public java.lang.String uriPath
        The UTF8 decoded path from the HTTP header.
      • nFields

        public int nFields
      • keys

        public java.lang.String[] keys
        Keys present in the HTTP header
      • versionRange

        public int versionRange
      • uriFragmentRange

        public int uriFragmentRange
      • queryStringRange

        public int queryStringRange
      • valueRanges

        public int[] valueRanges
      • contentOffset

        public int contentOffset
      • contentLength

        public int contentLength
      • iread

        public int iread
        The read cursor, used in the read* methods.
      • CR

        public static byte CR
      • LF

        public static byte LF
    • Constructor Detail

      • HttpRequest

        public HttpRequest()
    • Method Detail

      • getHeader

        public java.lang.String getHeader​(java.lang.String key)
        Get the value for a given key
        Parameters:
        key -
        Returns:
        null if the key is not present in the header.
      • getQuery

        public java.lang.String getQuery()
        Returns:
        the query part of the URI.
      • version

        public java.lang.String version()
      • keepAlive

        public boolean keepAlive()
      • getQueryComponents

        public KeyValues getQueryComponents()
      • getQueryComponents

        public KeyValues getQueryComponents​(java.lang.String q)
      • uriFragment

        public java.lang.String uriFragment()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isOldHttp

        public boolean isOldHttp()
        Returns:
        true if version is 1.0 or earlier
      • reuse

        public void reuse()
        Clear the request object so that it can be reused for the next message.
      • readFrom

        public void readFrom​(EndPoint endpoint)
                      throws Pausable,
                             java.io.IOException
        Throws:
        Pausable
        java.io.IOException
      • readHeader

        public void readHeader​(EndPoint endpoint)
                        throws Pausable,
                               java.io.IOException
        Throws:
        Pausable
        java.io.IOException
      • dumpBuffer

        public void dumpBuffer​(java.nio.ByteBuffer buffer)
      • addField

        public void addField​(java.lang.String key,
                             int valRange)
      • extractRange

        public java.lang.String extractRange​(int range)
      • extractRange

        public java.lang.String extractRange​(int beg,
                                             int end)
      • extractBytes

        public byte[] extractBytes​(int beg,
                                   int end)
      • readBody

        public void readBody​(EndPoint endpoint)
                      throws Pausable,
                             java.io.IOException
        Throws:
        Pausable
        java.io.IOException
      • readTrailers

        public void readTrailers​(EndPoint endpoint)
      • readAllChunks

        public void readAllChunks​(EndPoint endpoint)
                           throws java.io.IOException,
                                  Pausable
        Throws:
        java.io.IOException
        Pausable
      • parseChunkSize

        public static int parseChunkSize​(java.nio.ByteBuffer buffer,
                                         int start,
                                         int end)
                                  throws java.io.IOException
        Throws:
        java.io.IOException
      • fill

        public void fill​(EndPoint endpoint,
                         int offset,
                         int size)
                  throws java.io.IOException,
                         Pausable
        Throws:
        java.io.IOException
        Pausable
      • readLine

        public int readLine​(EndPoint endpoint)
                     throws java.io.IOException,
                            Pausable
        Throws:
        java.io.IOException
        Pausable