# &adminguide;

## Overview

This module provides an HTTP transport layer for &osips;.

Implementation of httpd module's http server is based on libmicrohttpd library.

## Dependencies

### &osips; Modules

The following modules must be loaded before this module:

- No dependencies on other &osips; modules.

### External Libraries or Applications

The following libraries or applications must be installed before running &osips; with this module loaded:

- libmicrohttpd.

## Exported Parameters

### `ip`(string)

The IP address used by the HTTP server to listen for incoming requests.

The default value is an empty string. If no IP address is set, then the http server will bind to all available IPs.

#### Set `ip` parameter

    ...
    modparam("httpd", "ip", "127.0.0.1")
    ...

### `port`(integer)

The port number used by the HTTP server to listen for incoming requests.

The default value is 8888. Ports lower than 1024 are not accepted.

#### Set `port` parameter

    ...
    modparam("httpd", "port", 8000)
    ...

### `buf_size` (integer)

It specifies the maximum length (in bytes) of the buffer used to write in the html response.

If the size of the buffer is set to zero, it will be automatically set to a quarter of the size of the pkg memory.

The default value is 0.

#### Set `buf_size` parameter

    ...
    modparam("httpd", "buf_size", 524288)
    ...

### `post_buf_size` (integer)

It specifies the length (in bytes) of the POST HTTP requests processing buffer. For large POST request, the default value might require to be increased.

The default value is 1024. The minumal value is 256.

#### Set `post_buf_size` parameter

    ...
    modparam("httpd", "post_buf_size", 4096)
    ...

## Exported MI Functions

### `httpd_list_root_path`

Lists all the registered http root paths into the httpd module. When a request comes in, if the root parth is in the list, the request will be sent to the module that register it.

Name: httpd_list_root_path

Parameters: none

MI FIFO Command Format:

    :httpd_list_root_path:_reply_fifo_file_
    _empty_line_

## Exported Functions

No function exported to be used from configuration file.

## Known issues

Due to the fact that &osips; is a multiprocess application, the microhttpd library is used in "external select" mode. This ensures that the library is not running in multithread mode and the library is entirely controled by &osips;. Due to this particular mode of operations, for now, the entire http response is built in a pre-allocated buffer (see buf_size parameter).

Future realeases of this module will address this issue.

Running the http daemon as non root on ports below 1024 is forbidden by default in linux (kernel>=2.6.24). To allow the port binding, one can use setcap to give extra privilleges to opensips binary:

    setcap 'cap_net_bind_service=+ep' /usr/local/sbin/opensips