SK.gnome.dwarf.http
Class HTTPParameters

java.lang.Object
  extended bySK.gnome.dwarf.GenericService
      extended bySK.gnome.dwarf.ParametersService
          extended bySK.gnome.dwarf.http.HTTPParameters
All Implemented Interfaces:
SK.gnome.dwarf.Parameters, SK.gnome.dwarf.Reportable, SK.gnome.dwarf.Service

public final class HTTPParameters
extends SK.gnome.dwarf.ParametersService

Provides the HTTP parameters.

An instance of this class may be added to the HTTPServer to provide a set of the HTTP-related runtime parameters. The parameters are by default available to the server and all its nested services.

Each parameter is represented by a protected field with its setter and getter methods, which can be used to manipulate the parameter from the outside world. This class provides also a few encoding-related static methods, which are also used by the HTTP server.

Note that some of the parameters are read-only while others may be modified in runtime either via the server console, or programatically.


Field Summary
protected  boolean allowKeepAlive
          Enables or disables persistent (keep-alive) connections.
protected  SK.gnome.dwarf.utils.StringProperties encodings
          Returns mapping between MIME charsets and Java encodings.
protected  SK.gnome.dwarf.utils.StringProperties errorCodes
          Returns mapping between HTTP error codes and reason-phrases.
protected  boolean extendedServerInfo
          Enables or disables the extended server information.
protected  boolean fileRequestBody
          Whether or not to store the request entity body in a temporary file.
protected  SK.gnome.dwarf.utils.StringProperties charsets
          Returns mapping between Java locales and MIME charsets.
protected  int keepAliveTimeout
          Number of seconds to wait for the next request from the persistent connection.
protected  int maxRequestBodySize
          Returns maximum size of the request entity body in kB.
protected  SK.gnome.dwarf.utils.StringProperties mimeTypes
          Returns mapping between MIME types and file extensions.
protected  int requestsPerConnection
          Maximum number of requests allowed per one persistent connection.
protected  int requestTimeout
          Returns the maximum time in seconds to wait for the incoming request data.
protected  boolean sendErrors
          Enables or disables sending of detailed error messages to the client.
protected  boolean sendServerInfo
          Enables or disables exposing of the server information to the client.
protected  boolean useJikesForJSP
          Whether or not to use Jikes compiler to compile the JSP pages.
 
Fields inherited from class SK.gnome.dwarf.GenericService
initParameters, parent
 
Fields inherited from interface SK.gnome.dwarf.Service
INITIALIZED, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_TRACE, LOG_WARN, LOG_XFER, SHUTDOWN, STARTED, STOPPED
 
Constructor Summary
HTTPParameters(java.lang.String name)
          Creates a new HTTPParameters.
 
Method Summary
 boolean getAllowKeepAlive()
           
 SK.gnome.dwarf.utils.StringProperties getEncodings()
           
 SK.gnome.dwarf.utils.StringProperties getErrorCodes()
           
 boolean getExtendedServerInfo()
           
 boolean getFileRequestBody()
           
 SK.gnome.dwarf.utils.StringProperties getCharsets()
           
 java.lang.String getJavaEncoding(java.lang.String charset)
          Returns the Java encoding for the given MIME charset.
 int getKeepAliveTimeout()
           
 int getMaxRequestBodySize()
           
 java.lang.String getMIMECharset(java.util.Locale locale)
          Returns the MIME charset for the given Java locale.
 SK.gnome.dwarf.utils.StringProperties getMimeTypes()
           
 int getRequestsPerConnection()
           
 int getRequestTimeout()
           
 boolean getSendErrors()
           
 boolean getSendServerInfo()
           
 java.lang.String getStatusPhrase(int code)
          Returns the string phrase for the given status code.
 boolean getUseJikesForJSP()
           
 void init(SK.gnome.dwarf.Server parent)
           
 void setAllowKeepAlive(boolean value)
           
 void setEncodings(SK.gnome.dwarf.utils.StringProperties value)
           
 void setErrorCodes(SK.gnome.dwarf.utils.StringProperties value)
           
 void setExtendedServerInfo(boolean enable)
           
 void setFileRequestBody(boolean enable)
           
 void setCharsets(SK.gnome.dwarf.utils.StringProperties value)
           
 void setKeepAliveTimeout(int value)
           
 void setMaxRequestBodySize(int value)
           
 void setMimeTypes(SK.gnome.dwarf.utils.StringProperties value)
           
 void setRequestsPerConnection(int value)
           
 void setRequestTimeout(int value)
           
 void setSendErrors(boolean value)
           
 void setSendServerInfo(boolean enable)
           
 void setUseJikesForJSP(boolean enable)
           
 
Methods inherited from class SK.gnome.dwarf.ParametersService
readOnly, report
 
Methods inherited from class SK.gnome.dwarf.GenericService
getAuthenticator, getAuthFacility, getFullName, getInitParameter, getInitParameterNames, getLogFacility, getLogger, getName, getParameters, getPrincipal, getShutdownTimeout, getState, log, log, login, logout, setAuthFacility, setInitParameters, setLogFacility, shutdown, start, stop, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

sendServerInfo

protected boolean sendServerInfo
Enables or disables exposing of the server information to the client.

If enabled, the server will send the server identification in the Server: header of each HTTP response as well as in the server-generated HTML error messages.

The HTTP/1.1 specification encourages the servers to make this feature configurable since it can reveal some sensitive information to a possible attacker.

This parameter is read-only.

Default value: true


extendedServerInfo

protected boolean extendedServerInfo
Enables or disables the extended server information.

If enabled, an extended server information will be sent to the client in the HTTP reponse headers as well as the error messages generated by the server. The extended information includes details of the system platform and the JRE version.

This parameter is read-only.

Default value: false

See Also:
sendServerInfo

sendErrors

protected boolean sendErrors
Enables or disables sending of detailed error messages to the client.

If enabled, errors will be sent to the client with a detailed information about the current request, including the exception stack trace listing. Do not turn on this option in a production environment; use it for the debugging purposes only.

This parameter is modifiable.

Default value: false


requestTimeout

protected int requestTimeout
Returns the maximum time in seconds to wait for the incoming request data.

Each single attempt to read from the underlying socket while receiving the request is blocked just for this specified amount of time. It prevents the possible DOS attacks when client opens a connection to the server and starts sending the request data without finishing it.

This parameter is read-only.

Default value: 60


allowKeepAlive

protected boolean allowKeepAlive
Enables or disables persistent (keep-alive) connections.

Connection is persistent if it can be used to send and receive more than one HTTP request/response pair.

This parameter is read-only.

Default value: true


keepAliveTimeout

protected int keepAliveTimeout
Number of seconds to wait for the next request from the persistent connection.

Zero means no timeout, i.e. the server will wait forever. Basically, if there are more incoming requests than the available handlers, decreasing this value should help to eliminate possible delays between processing the particular requests.

This parameter is read-only.

Value: 15


requestsPerConnection

protected int requestsPerConnection
Maximum number of requests allowed per one persistent connection.

Increasing this value may increase the server performance as well as the efficiency of using the memory resources.

This parameter is read-only.

Value: 10


maxRequestBodySize

protected int maxRequestBodySize
Returns maximum size of the request entity body in kB.

This limits the size of the request entity body thus preventing the possible DOS attacks by frequent sending a huge amount of data by the malicious client.

Zero value means no limit.

This parameter is modifiable.

Default value: 0


fileRequestBody

protected boolean fileRequestBody
Whether or not to store the request entity body in a temporary file.

The request entity body may be stored in a temporary file instead of the operational memory if its total length exceeds a specified size. This may optimize usage of the memory resources when large amounts of data are being sent via HTTP requests to the server. A typical example of this is the file uploading process.

This parameter is read-only.

Default value: true

See Also:
HTTPConstants.HTTP_REQUEST_BODY_LIMIT

useJikesForJSP

protected boolean useJikesForJSP
Whether or not to use Jikes compiler to compile the JSP pages.

The Jikes compiler may be used instead of the default Sun's compiler, which requires the Java SDK to be installed. The compiler executable must be included in the current command path, i.e. one must be able to invoke it from the command line.

This parameter is read-only.

Default value: false


mimeTypes

protected SK.gnome.dwarf.utils.StringProperties mimeTypes
Returns mapping between MIME types and file extensions.

This parameter is read-only.

Default value: file:conf/samples/http/mimetypes.properties


encodings

protected SK.gnome.dwarf.utils.StringProperties encodings
Returns mapping between MIME charsets and Java encodings.

This parameter is read-only.

Default value: file:conf/samples/http/encodings.properties

See Also:
getJavaEncoding(String)

charsets

protected SK.gnome.dwarf.utils.StringProperties charsets
Returns mapping between Java locales and MIME charsets.

This parameter is read-only.

Default value: file:conf/samples/http/charsets.properties

See Also:
getMIMECharset(Locale)

errorCodes

protected SK.gnome.dwarf.utils.StringProperties errorCodes
Returns mapping between HTTP error codes and reason-phrases.

This parameter is read-only.

Default value: file:conf/samples/http/errcodes.properties

See Also:
getStatusPhrase(int)
Constructor Detail

HTTPParameters

public HTTPParameters(java.lang.String name)
Creates a new HTTPParameters.

Method Detail

init

public void init(SK.gnome.dwarf.Server parent)
          throws SK.gnome.dwarf.ServiceException
Throws:
SK.gnome.dwarf.ServiceException

getJavaEncoding

public java.lang.String getJavaEncoding(java.lang.String charset)
Returns the Java encoding for the given MIME charset.

This method maps MIME charsets to Java encoding identifiers. If no Java encoding can be found for the given charset, the null is returned.

Parameters:
charset - the charset
Returns:
the Java encoding or null

getMIMECharset

public java.lang.String getMIMECharset(java.util.Locale locale)
Returns the MIME charset for the given Java locale.

This method maps Java locales to MIME charsets. Either the locale string representation or the locale language is used to obtain the charset. The string representation is checked before the language string.

Parameters:
locale - the locale
Returns:
the charset

getStatusPhrase

public java.lang.String getStatusPhrase(int code)
Returns the string phrase for the given status code.

This method maps numerical HTTP status codes to their string phrases.

Parameters:
code - the numerical status code
Returns:
the status phrase for the given code

getSendServerInfo

public boolean getSendServerInfo()

setSendServerInfo

public void setSendServerInfo(boolean enable)

getExtendedServerInfo

public boolean getExtendedServerInfo()

setExtendedServerInfo

public void setExtendedServerInfo(boolean enable)

getSendErrors

public boolean getSendErrors()

setSendErrors

public void setSendErrors(boolean value)

getRequestTimeout

public int getRequestTimeout()

setRequestTimeout

public void setRequestTimeout(int value)

getAllowKeepAlive

public boolean getAllowKeepAlive()

setAllowKeepAlive

public void setAllowKeepAlive(boolean value)

getKeepAliveTimeout

public int getKeepAliveTimeout()

setKeepAliveTimeout

public void setKeepAliveTimeout(int value)

getRequestsPerConnection

public int getRequestsPerConnection()

setRequestsPerConnection

public void setRequestsPerConnection(int value)

getMaxRequestBodySize

public int getMaxRequestBodySize()

setMaxRequestBodySize

public void setMaxRequestBodySize(int value)

getFileRequestBody

public boolean getFileRequestBody()

setFileRequestBody

public void setFileRequestBody(boolean enable)

getUseJikesForJSP

public boolean getUseJikesForJSP()

setUseJikesForJSP

public void setUseJikesForJSP(boolean enable)

getMimeTypes

public SK.gnome.dwarf.utils.StringProperties getMimeTypes()

setMimeTypes

public void setMimeTypes(SK.gnome.dwarf.utils.StringProperties value)

getEncodings

public SK.gnome.dwarf.utils.StringProperties getEncodings()

setEncodings

public void setEncodings(SK.gnome.dwarf.utils.StringProperties value)

getCharsets

public SK.gnome.dwarf.utils.StringProperties getCharsets()

setCharsets

public void setCharsets(SK.gnome.dwarf.utils.StringProperties value)

getErrorCodes

public SK.gnome.dwarf.utils.StringProperties getErrorCodes()

setErrorCodes

public void setErrorCodes(SK.gnome.dwarf.utils.StringProperties value)


Copyright (c) 1999-2005, Gnome Ltd. All rights reserved.