|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.util.httpd.NanoHTTPD
public class NanoHTTPD
A simple, tiny, nicely embeddable HTTP 1.0 server in Java
NanoHTTPD version 1.1, Copyright © 2001,2005-2007 Jarno Elonen (elonen@iki.fi, http://iki.fi/elonen/)
Various modifications since supporting integration within bigdata services © 2008, SYSTAP, LLC.
Features + limitations:
Ways to use:
| Nested Class Summary | |
|---|---|
class |
NanoHTTPD.Response
HTTP response. |
| Nested classes/interfaces inherited from interface com.bigdata.service.IServiceShutdown |
|---|
IServiceShutdown.Options |
| Field Summary | |
|---|---|
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_METHOD_NOT_ALLOWED
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_OK
Some HTTP response status codes |
static String |
HTTP_REDIRECT
Some HTTP response status codes |
static org.apache.log4j.Logger |
log
|
static String |
MIME_APPLICATION_XML
Common mime types for dynamic content |
static String |
MIME_DEFAULT_BINARY
Common mime types for dynamic content |
static String |
MIME_TEXT_HTML
Common mime types for dynamic content |
static String |
MIME_TEXT_JAVASCRIPT
Common mime types for dynamic content |
static String |
MIME_TEXT_PLAIN
Common mime types for dynamic content |
| Constructor Summary | |
|---|---|
NanoHTTPD(int port)
Starts a HTTP server to given port. |
|
| Method Summary | |
|---|---|
static LinkedHashMap<String,Vector<String>> |
decodeParms(String parms)
Decodes parameters in percent-encoded URI-format ( e.g. |
int |
getPort()
The port on which the service was started. |
boolean |
isOpen()
Return true iff the service is running. |
static void |
main(String[] args)
Starts as a standalone file server and waits for Enter. |
NanoHTTPD.Response |
serve(String uri,
String method,
Properties header,
LinkedHashMap<String,Vector<String>> 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 |
shutdown()
The service will no longer accept new requests, but existing requests will be processed (sychronous). |
void |
shutdownNow()
The service will no longer accept new requests and will make a best effort attempt to terminate all existing requests and return ASAP. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final org.apache.log4j.Logger log
public static final String HTTP_OK
public static final String HTTP_REDIRECT
public static final String HTTP_FORBIDDEN
public static final String HTTP_NOTFOUND
public static final String HTTP_BADREQUEST
public static final String HTTP_METHOD_NOT_ALLOWED
public static final String HTTP_INTERNALERROR
public static final String HTTP_NOTIMPLEMENTED
public static final String MIME_TEXT_PLAIN
public static final String MIME_TEXT_HTML
public static final String MIME_DEFAULT_BINARY
public static final String MIME_APPLICATION_XML
public static final String MIME_TEXT_JAVASCRIPT
| Constructor Detail |
|---|
public NanoHTTPD(int port)
throws IOException
Throws an IOException if the socket is already in use
port - The port. If 0 the the server will start on a
random port. The actual port is available from #getPort().
IOException| Method Detail |
|---|
public NanoHTTPD.Response serve(String uri,
String method,
Properties header,
LinkedHashMap<String,Vector<String>> 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. The keys are the parameter names. Each value is a
Collection of Strings containing the bindings
for the named parameter. The order of the URL parameters is
preserved.header - Header entries, percent decoded
public boolean isOpen()
IServiceShutdowntrue iff the service is running.
isOpen in interface IServiceShutdownpublic void shutdown()
IServiceShutdownIServiceShutdown.Options.SHUTDOWN_TIMEOUT. Implementations SHOULD be
synchronized. If the service is aleady shutdown, then
this method should be a NOP.
shutdown in interface IServiceShutdownpublic void shutdownNow()
IServiceShutdown
shutdownNow in interface IServiceShutdownpublic static void main(String[] args)
public int getPort()
public NanoHTTPD.Response serveFile(String uri,
Properties header,
File homeDir,
boolean allowDirectoryListing)
public static LinkedHashMap<String,Vector<String>> decodeParms(String parms)
throws UnsupportedEncodingException
Map
.
Vector of
Strings containing the bindings for the named parameter.
The order of the URL parameters is preserved by the insertion
order of the LinkedHashMap and the elements of the
Vector values.
UnsupportedEncodingException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||