public class NanoHTTPD
extends java.lang.Object
NanoHTTPD version 1.05, Copyright © 2001,2005,2006 Jarno Elonen (elonen@iki.fi, http://iki.fi/elonen/)
Features & limitations:
Raffi-Modifications:
Ways to use:
Modifier and Type | Class and Description |
---|---|
class |
NanoHTTPD.Response
HTTP response.
|
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
HTTP_BADREQUEST
Some HTTP response status codes
|
static java.lang.String |
HTTP_FORBIDDEN
Some HTTP response status codes
|
static java.lang.String |
HTTP_INTERNALERROR
Some HTTP response status codes
|
static java.lang.String |
HTTP_NOT_MODIFIED
Some HTTP response status codes
|
static java.lang.String |
HTTP_NOTFOUND
Some HTTP response status codes
|
static java.lang.String |
HTTP_NOTIMPLEMENTED
Some HTTP response status codes
|
static java.lang.String |
HTTP_OK
Some HTTP response status codes
|
static java.lang.String |
HTTP_REDIRECT
Some HTTP response status codes
|
static java.lang.String |
MIME_DEFAULT_BINARY
Common mime types for dynamic content
|
static java.lang.String |
MIME_HTML
Common mime types for dynamic content
|
static java.lang.String |
MIME_PLAINTEXT
Common mime types for dynamic content
|
Constructor and Description |
---|
NanoHTTPD(int port)
Inits an HTTP server to given port.
|
NanoHTTPD(int port,
boolean listen)
Inits an HTTP server to given port.
|
Modifier and Type | Method and Description |
---|---|
void |
listen()
Starts the HTTP server listening on the port it was initialized with
|
static void |
main(java.lang.String[] args)
Starts as a standalone file server and waits for Enter.
|
NanoHTTPD.Response |
serve(java.lang.String uri,
java.lang.String method,
java.util.Properties header,
java.util.Properties parms)
Override this to customize the server.
|
NanoHTTPD.Response |
serveFile(java.lang.String uri,
java.util.Properties header,
java.io.File homeDir,
boolean allowDirectoryListing)
Serves file from homeDir and its' subdirectories (only).
|
public static final java.lang.String HTTP_OK
public static final java.lang.String HTTP_REDIRECT
public static final java.lang.String HTTP_NOT_MODIFIED
public static final java.lang.String HTTP_FORBIDDEN
public static final java.lang.String HTTP_NOTFOUND
public static final java.lang.String HTTP_BADREQUEST
public static final java.lang.String HTTP_INTERNALERROR
public static final java.lang.String HTTP_NOTIMPLEMENTED
public static final java.lang.String MIME_PLAINTEXT
public static final java.lang.String MIME_HTML
public static final java.lang.String MIME_DEFAULT_BINARY
public NanoHTTPD(int port) throws java.io.IOException
Throws an IOException if the socket is already in use
java.io.IOException
public NanoHTTPD(int port, boolean listen) throws java.io.IOException
java.io.IOException
public NanoHTTPD.Response serve(java.lang.String uri, java.lang.String method, java.util.Properties header, java.util.Properties parms)
(By default, this delegates to serveFile() and allows directory listing.)
public void listen() throws java.io.IOException
java.io.IOException
public static void main(java.lang.String[] args)
public NanoHTTPD.Response serveFile(java.lang.String uri, java.util.Properties header, java.io.File homeDir, boolean allowDirectoryListing)