public class NanoHTTPD extends Object
NanoHTTPD version 1.25, Copyright © 2001,2005-2012 Jarno Elonen (elonen@iki.fi, http://iki.fi/elonen/) and Copyright © 2010 Konstantinos Togias (info@ktogias.gr, http://ktogias.gr)
Features + limitations:
Ways to use:
| Modifier and Type | Class and Description |
|---|---|
class |
NanoHTTPD.Response
HTTP response.
|
| Modifier and Type | Field and Description |
|---|---|
static String |
HTTP_BADREQUEST
Some HTTP response status codes
|
static String |
HTTP_FORBIDDEN
Some HTTP response status codes
|
static String |
HTTP_INTERNALERROR
Some HTTP response status codes
|
static String |
HTTP_NOTFOUND
Some HTTP response status codes
|
static String |
HTTP_NOTIMPLEMENTED
Some HTTP response status codes
|
static String |
HTTP_NOTMODIFIED
Some HTTP response status codes
|
static String |
HTTP_OK
Some HTTP response status codes
|
static String |
HTTP_PARTIALCONTENT
Some HTTP response status codes
|
static String |
HTTP_RANGE_NOT_SATISFIABLE
Some HTTP response status codes
|
static String |
HTTP_REDIRECT
Some HTTP response status codes
|
static String |
HTTP_TOOLONGREQUEST
Some HTTP response status codes
|
static String |
HTTP_UNAUTHORIZED
Some HTTP response status codes
|
static String |
MIME_DEFAULT_BINARY
Common mime types for dynamic content
|
static String |
MIME_HTML
Common mime types for dynamic content
|
static String |
MIME_JSON
Common mime types for dynamic content
|
static String |
MIME_PLAINTEXT
Common mime types for dynamic content
|
static String |
MIME_XML
Common mime types for dynamic content
|
protected static PrintStream |
myOut |
| Constructor and Description |
|---|
NanoHTTPD(ServerSocket socket,
File wwwroot)
Starts a HTTP server to given port.
|
| Modifier and Type | Method and Description |
|---|---|
static void |
main(String[] args)
Starts as a standalone file server and waits for Enter.
|
NanoHTTPD.Response |
serve(String uri,
String method,
Properties header,
Properties parms)
Override this to customize the server.
|
NanoHTTPD.Response |
serveFile(String uri,
Properties header,
File homeDir,
boolean allowDirectoryListing)
Serves file from homeDir and its' subdirectories (only).
|
void |
stop()
Stops the server.
|
public static final String HTTP_OK
public static final String HTTP_PARTIALCONTENT
public static final String HTTP_RANGE_NOT_SATISFIABLE
public static final String HTTP_REDIRECT
public static final String HTTP_NOTMODIFIED
public static final String HTTP_FORBIDDEN
public static final String HTTP_UNAUTHORIZED
public static final String HTTP_NOTFOUND
public static final String HTTP_BADREQUEST
public static final String HTTP_TOOLONGREQUEST
public static final String HTTP_INTERNALERROR
public static final String HTTP_NOTIMPLEMENTED
public static final String MIME_PLAINTEXT
public static final String MIME_HTML
public static final String MIME_JSON
public static final String MIME_DEFAULT_BINARY
public static final String MIME_XML
protected static final PrintStream myOut
public NanoHTTPD(ServerSocket socket, File wwwroot) throws IOException
Throws an IOException if the socket is already in use
IOExceptionpublic NanoHTTPD.Response serve(String uri, String method, Properties header, Properties parms)
(By default, this delegates to serveFile() and allows directory listing.)
uri - Percent-decoded URI without parameters, for example "/index.cgi"method - "GET", "POST" etc.parms - Parsed, percent decoded parameters from URI and, in case of POST, data.header - Header entries, percent decodedpublic void stop()
public static void main(String[] args)
public NanoHTTPD.Response serveFile(String uri, Properties header, File homeDir, boolean allowDirectoryListing)
Copyright © 2013–2014 0xdata. All rights reserved.