Package fi.iki.elonen

Class NanoHTTPD.HTTPSession

    • Field Detail

      • outputStream

        private final java.io.OutputStream outputStream
      • inputStream

        private final java.io.BufferedInputStream inputStream
      • splitbyte

        private int splitbyte
      • rlen

        private int rlen
      • uri

        private java.lang.String uri
      • parms

        private java.util.Map<java.lang.String,​java.util.List<java.lang.String>> parms
      • headers

        private java.util.Map<java.lang.String,​java.lang.String> headers
      • queryParameterString

        private java.lang.String queryParameterString
      • remoteIp

        private java.lang.String remoteIp
      • remoteHostname

        private java.lang.String remoteHostname
      • protocolVersion

        private java.lang.String protocolVersion
    • Constructor Detail

      • HTTPSession

        public HTTPSession​(NanoHTTPD.TempFileManager tempFileManager,
                           java.io.InputStream inputStream,
                           java.io.OutputStream outputStream)
      • HTTPSession

        public HTTPSession​(NanoHTTPD.TempFileManager tempFileManager,
                           java.io.InputStream inputStream,
                           java.io.OutputStream outputStream,
                           java.net.InetAddress inetAddress)
    • Method Detail

      • decodeHeader

        private void decodeHeader​(java.io.BufferedReader in,
                                  java.util.Map<java.lang.String,​java.lang.String> pre,
                                  java.util.Map<java.lang.String,​java.util.List<java.lang.String>> parms,
                                  java.util.Map<java.lang.String,​java.lang.String> headers)
                           throws NanoHTTPD.ResponseException
        Decodes the sent headers and loads the data into Key/value pairs
        Throws:
        NanoHTTPD.ResponseException
      • decodeMultipartFormData

        private void decodeMultipartFormData​(NanoHTTPD.ContentType contentType,
                                             java.nio.ByteBuffer fbuf,
                                             java.util.Map<java.lang.String,​java.util.List<java.lang.String>> parms,
                                             java.util.Map<java.lang.String,​java.lang.String> files)
                                      throws NanoHTTPD.ResponseException
        Decodes the Multipart Body data and put it into Key/Value pairs.
        Throws:
        NanoHTTPD.ResponseException
      • scipOverNewLine

        private int scipOverNewLine​(byte[] partHeaderBuff,
                                    int index)
      • decodeParms

        private void decodeParms​(java.lang.String parms,
                                 java.util.Map<java.lang.String,​java.util.List<java.lang.String>> p)
        Decodes parameters in percent-encoded URI-format ( e.g. "name=Jack%20Daniels&pass=Single%20Malt" ) and adds them to given Map.
      • execute

        public void execute()
                     throws java.io.IOException
        Specified by:
        execute in interface NanoHTTPD.IHTTPSession
        Throws:
        java.io.IOException
      • findHeaderEnd

        private int findHeaderEnd​(byte[] buf,
                                  int rlen)
        Find byte index separating header from body. It must be the last byte of the first two sequential new lines.
      • getBoundaryPositions

        private int[] getBoundaryPositions​(java.nio.ByteBuffer b,
                                           byte[] boundary)
        Find the byte positions where multipart boundaries start. This reads a large block at a time and uses a temporary buffer to optimize (memory mapped) file access.
      • getParms

        @Deprecated
        public final java.util.Map<java.lang.String,​java.lang.String> getParms()
        Deprecated.
        use getParameters() instead.
        Description copied from interface: NanoHTTPD.IHTTPSession
        This method will only return the first value for a given parameter. You will want to use getParameters if you expect multiple values for a given key.
        Specified by:
        getParms in interface NanoHTTPD.IHTTPSession
      • getParameters

        public final java.util.Map<java.lang.String,​java.util.List<java.lang.String>> getParameters()
        Specified by:
        getParameters in interface NanoHTTPD.IHTTPSession
      • getTmpBucket

        private java.io.RandomAccessFile getTmpBucket()
      • getUri

        public final java.lang.String getUri()
        Specified by:
        getUri in interface NanoHTTPD.IHTTPSession
        Returns:
        the path part of the URL.
      • getBodySize

        public long getBodySize()
        Deduce body length in bytes. Either from "content-length" header or read bytes.
      • saveTmpFile

        private java.lang.String saveTmpFile​(java.nio.ByteBuffer b,
                                             int offset,
                                             int len,
                                             java.lang.String filename_hint)
        Retrieves the content of a sent file and saves it to a temporary file. The full path to the saved file is returned.