com.ldodds.http.responder
Class Server

java.lang.Object
  |
  +--com.ldodds.http.responder.Server
All Implemented Interfaces:
java.lang.Runnable

public class Server
extends java.lang.Object
implements java.lang.Runnable

A very simple, light-weight HTTP Server. Adapted from the source of the Sun RMI HTTP class loader.

This class isn't designed to be a general purpose HTTP server, and doesn't attempt to offer a wide range of functionality. Its sole purpose is to provide an HTTP interface (specifically GET requests) that can be used to feed information into the FOAF-a-Matic from the users browser.

With this in mind the server will also only respond to requests from the local machine. This should also limit any potential security loop-holes.

Author:
ldodds

Field Summary
static int DEFAULT_PORT
           
static java.lang.String DIR_MARKER
           
static java.lang.String PARAM_MARKER
           
static java.lang.String PARAM_SEPARATOR
           
 
Constructor Summary
Server()
          Constructor for Server.
Server(int port)
           
Server(int port, com.ldodds.http.responder.ResponderFactory factory)
           
 
Method Summary
static java.lang.String getPathAndParameters(java.io.DataInputStream in)
          Parse out the path and parameter part of the url.
 com.ldodds.http.responder.ResponderFactory getResponderFactory()
           
static java.util.Map parseParameters(java.lang.String path)
          Builds a Map of parameters parsed from a path string produced by getPathAndParameters.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_PORT

public static final int DEFAULT_PORT
See Also:
Constant Field Values

DIR_MARKER

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

PARAM_MARKER

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

PARAM_SEPARATOR

public static final java.lang.String PARAM_SEPARATOR
See Also:
Constant Field Values
Constructor Detail

Server

public Server()
       throws java.io.IOException
Constructor for Server.


Server

public Server(int port)
       throws java.io.IOException

Server

public Server(int port,
              com.ldodds.http.responder.ResponderFactory factory)
       throws java.io.IOException
Method Detail

getPathAndParameters

public static java.lang.String getPathAndParameters(java.io.DataInputStream in)
                                             throws java.io.IOException
Parse out the path and parameter part of the url. e.g. for http://www.foo.com/bar?a=b then path will be bar?a=b

java.io.IOException

parseParameters

public static java.util.Map parseParameters(java.lang.String path)
Builds a Map of parameters parsed from a path string produced by getPathAndParameters.


run

public void run()
Specified by:
run in interface java.lang.Runnable

getResponderFactory

public com.ldodds.http.responder.ResponderFactory getResponderFactory()