Bundle: http
Version 5.1.0

Http server

Small footprint OSGi HTTP server implementation for embedded use. The HTTP server allows bundles to register resources as servlets, web pages, images or multimedia into a web server running on the framework.

Usage

The HTTP bundle can be configured by both CM or System properties

As soon as the http bundle gets a valid configuration it creates and registers an HttpService instance into the framework.

To use HTTPS a bundle providing a SslServerSocketFactory must be installed. E.g., SSL Provider — J2SP.

Note: If the server fails to bind to a port, an HttpService will still be registered, but the service property "port" will not be present!

Console Commands

The HTTP server has the built-in console command group http. The command group shows information about configuration, servlet and resource registrations, as well as transaction status of the HTTP server.
Usage: list [-help] [-c] [-r] [-t] [-l]
  List all the configured HTTP servers
  -c  Show configuration info
  -r  Show all registrations, servlets and resources
  -t  Show info on transactions
  -l  List in long format, same as supplying -c -r -t, providing extensive details

Configuration using Framework Properties

Name Description Type Default
org.knopflerfish.http.enabled If true, the bundle will start to listen in the http port. boolean true
org.knopflerfish.http.secure.enabled If true, the bundle will start to listen in the https port. Note: This functionality requires that the bundle is able to obtain a SslServerSocketFactory service instance from the frameworks service registry. boolean true
org.osgi.service.http.port Port number that the HTTP server will listen for http-requests on. int 80
org.osgi.service.http.secure.port Port number that the HTTP server will listen for https-requests on. int 443
org.osgi.service.http.hostname Host (IP interface name) to open the HTTP server socket on. An empty string means all available interfaces. String
org.knopflerfish.http.mime.props URL to properties file defining MIME type mappings. The key in the properties file is the file name extension and the value is the associated MIME type. String
org.knopflerfish.http.dnslookup This boolean property decides if the server will use DNS lookup when a servlet calls the HttpServletRequest.getRemoteHost method. In some environments DNS lookup will cause the current transaction to hang for a long period of time. boolean false
org.knopflerfish.http.response.buffer.size.default This integer property decides the default buffer size in bytes for an HTTP response. If a servlet or publisher does not exceed this buffer, the server will calculate and send the content length header in the response. If the buffer is exceeded the servlet or publisher need to set the content length header explicitly. The content length header is required for persistent connections. If the content length is unknown the server will send a connection close header. The buffer size can be set runtime by the servlet using the HttpResponse.setBufferSize() method. int 16384
org.knopflerfish.http.connection.max This integer property decides the maximum number of concurrent connections to the HTTP server. int 50
org.knopflerfish.http.connection.timeout This integer property decides the timeout in seconds for a persistent connection to the HTTP server. int 30
org.knopflerfish.http.session.timeout.default This integer property decides the default timeout in seconds for an HTTP session. int 1200
org.knopflerfish.http.encoding.default The default character encoding to use for text in the HTTP response. String ISO-8859-1
org.knopflerfish.http.req.client.auth If client authentication shall be required or not when using https. boolean false
org.knopflerfish.http.trace.enabled If the TRACE method shall be enabled or not boolean false
org.knopflerfish.http.limit.requestline Defines the maximum length of an HTTP request line. This limit is also applied for HTTP header lines. When exceeding this limit a 413 response is returned - Request Entity Too Large. int 8190
org.knopflerfish.http.limit.requestheaders Defines the maximum number of headers accepted per request. When exceeding this limit a 413 response is returned - Request Entity Too Large. int 100
org.knopflerfish.http.limit.postsize Defines the maximum content size for a POST request. A value of -1 indicates there is no limit. This is also the default behaviour. When exceeding this limit a 413 response is returned - Request Entity Too Large. int -1
org.knopflerfish.http.threads.max Defines the maximum number of worker threads for handling HTTP requests int 5
org.knopflerfish.http.threads.keep_alive Defines the maximum number of worker threads that are allowed to maintain an open connection. Should always be at least one less than max threads. int 4
org.knopflerfish.http.threads.idle_timeout Defines the timeout in milliseconds after which an idle thread stops. int 15 000
org.knopflerfish.http.always_compress.mime_types Defines a comma-separated list of mime types whos response always will be compressed automatically. Just specifying the type and leaving out the subtype applies compression to all subtypes E.g. "text" will apply to text/html, text/plain etc. Compressing all text resources is the default. Setting this value to blank ("") means no automatic compression. String text

Configuration using the Configuration Manager

The http bundle accepts Factory configurations on the PID
  org.knopflerfish.bundle.http.factory.HttpServer
..with the following properties:
http.enabled
If true, the bundle will start to listen in the http port.
https.enabled
If true, the bundle will start to listen in the https port. Note: This functionality requires that the bundle is able to obtain a SslServerSocketFactory service instance from the frameworks service registry.
port.http (Integer)
This integer property decides the default port for the server instance. The default port is 8080.
port.https (Integer)
This integer property decides the default port for HTTPS requests to the server instance. The default port is 8443.
host (String)
This string property decides the default hostname for the server instance. If the server is running on a multihomed machine this property will be used to decide which network interface the server will listen to. If this property is not set the server will listen to all network interfaces. The default is to listen to all network interfaces.
mime.map (Vector of String[2])
This property is a vector of arrays defining MIME type mappings. Each entry in the vector is an array with two elements where the first is the file name extension and the second is the associated MIME type. By default the most common file types are defined.
session.timeout.default (Integer)
This integer property decides the default timeout in seconds for an HTTP session. The default is 1200 seconds.
connection.timeout (Integer)
This integer property decides the timeout in seconds for a persistent connection to the HTTP server. The default is 30 seconds.
connection.max (Integer)
This integer property decides the maximum number of concurrent connections to the HTTP server. The default is 50.
dns.lookup (Boolean)
This boolean property decides if the server will use DNS lookup when a servlet calls the HttpServletRequest.getRemoteHost method. In some environments DNS lookup will cause the current transaction to hang for a long period of time. The default is to do DNS lookup.
response.buffer.size.default (Integer)
This integer property decides the default buffer size in bytes for an HTTP response. If a servlet or publisher does not exceed this buffer, the server will calculate and send the content length header in the response. If the buffer is exceeded the servlet or publisher need to set the content length header explicitly. The content length header is required for persistent connections. If the content length is unknown the server will send a connection close header. The buffer size can be set runtime by the servlet using the HttpResponse.setBufferSize() method. The default is 16384 bytes.
req.client.auth (Boolean)
If client authentication shall be required or not when using https. The default is false.
org.knopflerfish.http.encoding.default (String)
The default character encoding to use for text in the HTTP response. The default is ISO-8859-1.
org.knopflerfish.http.trace.enabled (Boolean)
If the TRACE method shall be enabled or not. The default is false.
org.knopflerfish.http.limit.requestline (Integer)
Defines the maximum length of an HTTP request line. This limit is also applied for HTTP header lines. When exceeding this limit a 413 response is returned - Request Entity Too Large. The default is 8190.
org.knopflerfish.http.limit.requestheaders (Integer)
Defines the maximum number of headers accepted per request. When exceeding this limit a 413 response is returned - Request Entity Too Large. The default is 100.
org.knopflerfish.http.limit.postsize (Integer)
Defines the maximum content size for a POST request. A value of -1 indicates there is no limit. This is also the default behaviour. When exceeding this limit a 413 response is returned - Request Entity Too Large. The default is -1 (no limit).

Bundle Jar docs

http_all-5.1.0
http_api-5.1.0
http-5.1.0

Exported Packages

PackageVersionProviders
org.knopflerfish.service.log1.2.0http_all-5.1.0
org.osgi.service.http1.2.1http_all-5.1.0, http_api-5.1.0