NanoHTTPd.Response
Modifier and Type | Field and Description |
---|---|
private HashMap<String,DynamicHelpResource> |
dynamicPages
Mapping of dynamically generated resources, indexed by relative URI
|
private ArrayList<String> |
roots
List of packages within which to search for
resources to serve
|
HTTP_BADREQUEST, HTTP_FORBIDDEN, HTTP_INTERNALERROR, HTTP_NOTFOUND, HTTP_NOTIMPLEMENTED, HTTP_OK, HTTP_REDIRECT, MIME_DEFAULT_BINARY, MIME_HTML, MIME_PLAINTEXT, MIME_XML, myServerSocket, theMimeTypes
Constructor and Description |
---|
JarHTTPd(int port) |
Modifier and Type | Method and Description |
---|---|
void |
addDynamicResource(String uri,
DynamicHelpResource resource)
Add mapping for a dynamically generated resource
|
void |
addRoot(String root) |
int |
getPort()
Get the port on which the server is listening.
|
NanoHTTPd.Response |
serve(String uri,
String method,
Properties header,
Properties parms,
Properties files)
Override of
NanoHTTPd . |
NanoHTTPd.Response |
serveJar(String uri,
Properties header)
Search for a JVM resource
|
NanoHTTPd.Response |
serveStream(InputStream stream,
Properties header,
int length,
String mime)
Serve data from a stream.
|
private final ArrayList<String> roots
private final HashMap<String,DynamicHelpResource> dynamicPages
public JarHTTPd(int port) throws IOException
port
- Port to use, or 0 to select any open portIOException
public int getPort()
public void addRoot(String root)
public void addDynamicResource(String uri, DynamicHelpResource resource)
public NanoHTTPd.Response serve(String uri, String method, Properties header, Properties parms, Properties files)
serve
in class NanoHTTPd
uri
- Percent-decoded URI without parameters, for example "/index.cgi"method
- "GET", "POST" etc.header
- Header entries, percent decodedparms
- Parsed, percent decoded parameters from URI and, in case of POST, data.public NanoHTTPd.Response serveJar(String uri, Properties header)
uri
- Resource to serve, relative to root
header
- Parsed HTTP request headerpublic NanoHTTPd.Response serveStream(InputStream stream, Properties header, int length, String mime)
stream
- Stream to serveheader
- Parsed HTTP request headerlength
- Number of bytes in the streammime
- MIME type of the resourceCopyright © 2023. All rights reserved.