org.eclipse.palamedes.gdl.connection
Class NanoHTTPD

java.lang.Object
  extended by org.eclipse.palamedes.gdl.connection.NanoHTTPD
Direct Known Subclasses:
PlayerProxy, PlayerServer

public class NanoHTTPD
extends java.lang.Object

A simple, tiny, nicely embeddable HTTP 1.0 server in Java

NanoHTTPD version 1.01, Copyright © 2001 Jarno Elonen (elonen@iki.fi, http://iki.fi/elonen/)

Features & limitations:

Ways to use:

See the end of the source file for distribution license (Modified BSD licence)


Field Summary
static java.lang.String MIME_DEFAULT_BINARY
           
static java.lang.String MIME_HTML
           
static java.lang.String MIME_PLAINTEXT
          Common MIME types for dynamic content
protected  java.io.File myFileDir
           
protected  java.lang.Thread server_thread
           
 
Constructor Summary
NanoHTTPD(int port)
          Starts a HTTP server to given port.
 
Method Summary
static void main(java.lang.String[] args)
          Starts as a stand-alone file server and waits for Enter.
 Response serve(java.lang.String uri, java.lang.String method, java.util.Properties header, java.util.Properties parms, java.lang.String data)
          Override this to customize the server.
 Response serveFile(java.lang.String uri, java.util.Properties header, java.io.File homeDir, boolean allowDirectoryListing)
          Serves file from homeDir and its' subdirectories (only).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MIME_PLAINTEXT

public static final java.lang.String MIME_PLAINTEXT
Common MIME types for dynamic content

See Also:
Constant Field Values

MIME_HTML

public static final java.lang.String MIME_HTML
See Also:
Constant Field Values

MIME_DEFAULT_BINARY

public static final java.lang.String MIME_DEFAULT_BINARY
See Also:
Constant Field Values

server_thread

protected java.lang.Thread server_thread

myFileDir

protected java.io.File myFileDir
Constructor Detail

NanoHTTPD

public NanoHTTPD(int port)
          throws java.io.IOException
Starts a HTTP server to given port.

Throws an IOException if the socket is already in use

Throws:
java.io.IOException
Method Detail

serve

public Response serve(java.lang.String uri,
                      java.lang.String method,
                      java.util.Properties header,
                      java.util.Properties parms,
                      java.lang.String data)
Override this to customize the server.

(By default, this delegates to serveFile() and allows directory listing.)

Parameters:
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 decoded
Returns:
HTTP response, see class Response for details

main

public static void main(java.lang.String[] args)
Starts as a stand-alone file server and waits for Enter.


serveFile

public Response serveFile(java.lang.String uri,
                          java.util.Properties header,
                          java.io.File homeDir,
                          boolean allowDirectoryListing)
Serves file from homeDir and its' subdirectories (only). Uses only URI, ignores all headers and HTTP parameters.