Package fi.iki.elonen
Class NanoHTTPD.HTTPSession
java.lang.Object
fi.iki.elonen.NanoHTTPD.HTTPSession
- All Implemented Interfaces:
NanoHTTPD.IHTTPSession
- Enclosing class:
NanoHTTPD
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
private NanoHTTPD.CookieHandler
private final BufferedInputStream
static final int
private static final int
private NanoHTTPD.Method
private final OutputStream
private String
private String
private String
private String
private static final int
private int
private int
private final NanoHTTPD.TempFileManager
private String
-
Constructor Summary
ConstructorsConstructorDescriptionHTTPSession
(NanoHTTPD.TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream) HTTPSession
(NanoHTTPD.TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream, InetAddress inetAddress) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
decodeHeader
(BufferedReader in, Map<String, String> pre, Map<String, List<String>> parms, Map<String, String> headers) Decodes the sent headers and loads the data into Key/value pairsprivate void
decodeMultipartFormData
(NanoHTTPD.ContentType contentType, ByteBuffer fbuf, Map<String, List<String>> parms, Map<String, String> files) Decodes the Multipart Body data and put it into Key/Value pairs.private void
Decodes parameters in percent-encoded URI-format ( e.g.void
execute()
private int
findHeaderEnd
(byte[] buf, int rlen) Find byte index separating header from body.long
Deduce body length in bytes.private int[]
getBoundaryPositions
(ByteBuffer b, byte[] boundary) Find the byte positions where multipart boundaries start.final InputStream
final NanoHTTPD.Method
getParms()
Deprecated.Get the remote hostname of the requester.Get the remote ip address of the requester.private RandomAccessFile
final String
getUri()
void
Adds the files in the request body to the files map.private String
saveTmpFile
(ByteBuffer b, int offset, int len, String filename_hint) Retrieves the content of a sent file and saves it to a temporary file.private int
scipOverNewLine
(byte[] partHeaderBuff, int index)
-
Field Details
-
REQUEST_BUFFER_LEN
private static final int REQUEST_BUFFER_LEN- See Also:
-
MEMORY_STORE_LIMIT
private static final int MEMORY_STORE_LIMIT- See Also:
-
BUFSIZE
public static final int BUFSIZE- See Also:
-
MAX_HEADER_SIZE
public static final int MAX_HEADER_SIZE- See Also:
-
tempFileManager
-
outputStream
-
inputStream
-
splitbyte
private int splitbyte -
rlen
private int rlen -
uri
-
method
-
parms
-
headers
-
cookies
-
queryParameterString
-
remoteIp
-
remoteHostname
-
protocolVersion
-
-
Constructor Details
-
HTTPSession
public HTTPSession(NanoHTTPD.TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream) -
HTTPSession
public HTTPSession(NanoHTTPD.TempFileManager tempFileManager, InputStream inputStream, OutputStream outputStream, InetAddress inetAddress)
-
-
Method Details
-
decodeHeader
private void decodeHeader(BufferedReader in, Map<String, String> pre, Map<String, throws NanoHTTPD.ResponseExceptionList<String>> parms, Map<String, String> headers) Decodes the sent headers and loads the data into Key/value pairs- Throws:
NanoHTTPD.ResponseException
-
decodeMultipartFormData
private void decodeMultipartFormData(NanoHTTPD.ContentType contentType, ByteBuffer fbuf, Map<String, List<String>> parms, Map<String, throws NanoHTTPD.ResponseExceptionString> files) Decodes the Multipart Body data and put it into Key/Value pairs.- Throws:
NanoHTTPD.ResponseException
-
scipOverNewLine
private int scipOverNewLine(byte[] partHeaderBuff, int index) -
decodeParms
Decodes parameters in percent-encoded URI-format ( e.g. "name=Jack%20Danielsinvalid input: '&pass'=Single%20Malt" ) and adds them to given Map. -
execute
- Specified by:
execute
in interfaceNanoHTTPD.IHTTPSession
- Throws:
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
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. -
getCookies
- Specified by:
getCookies
in interfaceNanoHTTPD.IHTTPSession
-
getHeaders
- Specified by:
getHeaders
in interfaceNanoHTTPD.IHTTPSession
-
getInputStream
- Specified by:
getInputStream
in interfaceNanoHTTPD.IHTTPSession
-
getMethod
- Specified by:
getMethod
in interfaceNanoHTTPD.IHTTPSession
-
getParms
Deprecated.usegetParameters()
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 interfaceNanoHTTPD.IHTTPSession
-
getParameters
- Specified by:
getParameters
in interfaceNanoHTTPD.IHTTPSession
-
getQueryParameterString
- Specified by:
getQueryParameterString
in interfaceNanoHTTPD.IHTTPSession
-
getTmpBucket
-
getUri
- Specified by:
getUri
in interfaceNanoHTTPD.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. -
parseBody
Description copied from interface:NanoHTTPD.IHTTPSession
Adds the files in the request body to the files map.- Specified by:
parseBody
in interfaceNanoHTTPD.IHTTPSession
- Parameters:
files
- map to modify- Throws:
IOException
NanoHTTPD.ResponseException
-
saveTmpFile
Retrieves the content of a sent file and saves it to a temporary file. The full path to the saved file is returned. -
getRemoteIpAddress
Description copied from interface:NanoHTTPD.IHTTPSession
Get the remote ip address of the requester.- Specified by:
getRemoteIpAddress
in interfaceNanoHTTPD.IHTTPSession
- Returns:
- the IP address.
-
getRemoteHostName
Description copied from interface:NanoHTTPD.IHTTPSession
Get the remote hostname of the requester.- Specified by:
getRemoteHostName
in interfaceNanoHTTPD.IHTTPSession
- Returns:
- the hostname.
-
getParameters()
instead.