INRIA & friends

fr.inrialpes.exmo.align.service
Class HTMLAServProfile

java.lang.Object
  extended byfr.inrialpes.exmo.align.service.HTMLAServProfile

public class HTMLAServProfile
extends java.lang.Object

HTMLAServProfile: an HTML provile for the Alignement server It embeds an HTTP server. See the end of the source file for distribution license (Modified BSD licence)


Nested Class Summary
private  class HTMLAServProfile.HTTPSession
          Handles one session, i.e.
 class HTMLAServProfile.Response
          HTTP response.
 
Field Summary
private static java.text.SimpleDateFormat gmtFrmt
          GMT date formatter
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_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
private static java.lang.String LICENCE
          The distribution licence
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
(package private)  java.io.File myFileDir
           
private  int myTcpPort
           
private static java.util.Hashtable theMimeTypes
          Hashtable mapping (String)FILENAME_EXTENSION -> (String)MIME_TYPE
 
Constructor Summary
HTMLAServProfile()
           
 
Method Summary
private  java.lang.String encodeUri(java.lang.String uri)
          URL-encodes everything between "/"-characters.
 void init(int port)
          Starts a HTTP server to given port.
 HTMLAServProfile.Response serve(java.lang.String uri, java.lang.String method, java.util.Properties header, java.util.Properties parms)
          Override this to customize the server.
 HTMLAServProfile.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

myTcpPort

private int myTcpPort

HTTP_OK

public static final java.lang.String HTTP_OK
Some HTTP response status codes

See Also:
Constant Field Values

HTTP_REDIRECT

public static final java.lang.String HTTP_REDIRECT
Some HTTP response status codes

See Also:
Constant Field Values

HTTP_FORBIDDEN

public static final java.lang.String HTTP_FORBIDDEN
Some HTTP response status codes

See Also:
Constant Field Values

HTTP_NOTFOUND

public static final java.lang.String HTTP_NOTFOUND
Some HTTP response status codes

See Also:
Constant Field Values

HTTP_BADREQUEST

public static final java.lang.String HTTP_BADREQUEST
Some HTTP response status codes

See Also:
Constant Field Values

HTTP_INTERNALERROR

public static final java.lang.String HTTP_INTERNALERROR
Some HTTP response status codes

See Also:
Constant Field Values

HTTP_NOTIMPLEMENTED

public static final java.lang.String HTTP_NOTIMPLEMENTED
Some HTTP response status codes

See Also:
Constant Field Values

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
Common mime types for dynamic content

See Also:
Constant Field Values

MIME_DEFAULT_BINARY

public static final java.lang.String MIME_DEFAULT_BINARY
Common mime types for dynamic content

See Also:
Constant Field Values

myFileDir

java.io.File myFileDir

theMimeTypes

private static java.util.Hashtable theMimeTypes
Hashtable mapping (String)FILENAME_EXTENSION -> (String)MIME_TYPE


gmtFrmt

private static java.text.SimpleDateFormat gmtFrmt
GMT date formatter


LICENCE

private static final java.lang.String LICENCE
The distribution licence

See Also:
Constant Field Values
Constructor Detail

HTMLAServProfile

public HTMLAServProfile()
Method Detail

init

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

Throws an IOException if the socket is already in use JE: use rather parameters

Throws:
java.io.IOException

serve

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

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

Returns:
HTTP response, see class Response for details

encodeUri

private java.lang.String encodeUri(java.lang.String uri)
URL-encodes everything between "/"-characters. Encodes spaces as '%20' instead of '+'.


serveFile

public HTMLAServProfile.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.


INRIA & friends

..no bottom yet...