Advanced ObjectServer HTTP Interface Configuration
Use the libnhttpd.json configuration file to provide extra configuration data to the embedded HTTP socket library, define a set of user-defined static elements, and map MIME types to file extensions.
The properties in the httpPort section
in the libnhttpd library configuration JSON file $OMNIHOME/etc/libnhttpd.json set
the number of users that can be connected to the interface at one
time.
The libnhttpd.json configuration file is edited to define MIME type settings and HTTP headers in HTTP responses that are returned by the HTTP interface and OSLC interface. To enable MIME type settings and HTTP headers, enable the NHttpd.ConfigFile property.
{
"_comment" : "This file provides additional configuration data to the embedded HTTP
socket library (libnhttpd).",
"httpPort" : {
"_comment" : "This section defines additional operational settings for any HTTP
port that is active.",
"maxConnections" : 500
},
"httpRequest" : {
"_comment" : "This section defines additional operational settings related to
HTTP requests received from clients.",
"maxContentLength" : 1048576
},
"httpResponse" : {
"_comment" : "This section defines a set of user defined static elements that
should be returned in an HTTP response, such as HTTP headers.",
"corsHeaders" : [
{
"name" : "Access-Control-Allow-Headers",
"value" : "Location"
},
{
"name" : "Access-Control-Expose-Headers",
"value" : "Location"
}
],
"httpHeaders" : [
]
},
"mimeTypes" : {
"_comment" : "This section maps MIME types to file extensions. It is used by
libnhttpd to determine the MIME type for a file that is to be served from its file serving URI.",
"application/json" : [
"json"
],
"application/rdf+xml" : [
"rdf"
],
"application/xslt+xml" : [
"xsl", "xslt"
],
"image/jpeg" : [
"jpg", "jpeg"
],
"image/gif" : [
"gif"
],
"image/png" : [
"png"
],
"text/css" : [
"css"
],
"text/javascript" : [
"js"
],
"text/HTML" : [
"htm", "html"
],
"text/plain" : [
"txt", "log"
],
"text/xml" : [
"xml"
]
}
}The following are the connection and
data values:- maxConnections
- Defines the maximum number of connections allowable at one time.
The default is
500. - maxContentLength
- Defines the maximum amount of data that can be sent to the server
in an HTTP request. If this value is exceeded, the request ends with
an HTTP 413 (request entity too large). The default is
1048576.
- httpResponse
- Defines the HTTP headers that are in the HTTP responses that are
returned by the HTTP interface and OLSC interface. It has the following
subsections:
- corsHeaders
- Overrides Cross-Origin Resource Sharing (CORS) HTTP headers. By default, the default headers are overridden to indicate that the Location HTTP header is allowed and exposed. This setting is required for HTTP 201 Create responses messages.
- httpHeaders
- For user-defined HTTP headers. These headers are added to all HTTP responses. Use this section to add static values for clients. A sample header is provided in the example.
- mimeTypes
- This section assigns a file extension, for example .html, to a MIME type. When file-serving is enabled, these definitions are used to determine the MIME type for the file. They also set the Content-Type HTTP header so that browsers can handle the file correctly. The $OMNIHOME/etc/libnhttpd/json file has a default set of MIME type settings that you can add to.