httpd Module

Edited by

Ovidiu Sas

Revision History
Revision $Rev: 8580 $$Date: 2011-11-21 14:51:00 -0500 (Mon, 21 Nov 2011) $

Table of Contents

1. Admin Guide
1.1. Overview
1.2. Dependencies
1.2.1. OpenSIPS Modules
1.2.2. External Libraries or Applications
1.3. Exported Parameters
1.3.1. ip(string)
1.3.2. port(integer)
1.3.3. buf_size (integer)
1.4. Exported MI Functions
1.4.1. httpd_list_root_path
1.5. Exported Functions
1.6. Known issues
2. Developer Guide
2.1. Available Functions
2.1.1. register_httpdcb (module, root_path, httpd_acces_handler_cb, httpd_flush_data_cb, httpd_init_proc_cb)

List of Examples

1.1. Set ip parameter
1.2. Set port parameter
1.3. Set buf_size parameter

Chapter 1. Admin Guide

1.1. Overview

This module provides an HTTP transport layer for OpenSIPS.

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

1.2. Dependencies

1.2.1. OpenSIPS Modules

The following modules must be loaded before this module:

  • No dependencies on other OpenSIPS modules.

1.2.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • libmicrohttpd.

1.3. Exported Parameters

1.3.1. 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.

Example 1.1. Set ip parameter

modparam("httpd", "ip", "")

1.3.2. 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.

Example 1.2. Set port parameter

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

1.3.3. buf_size (integer)

It specifies the maximum length 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.

Example 1.3. Set buf_size parameter

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

1.4. Exported MI Functions

1.4.1. 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:


1.5. Exported Functions

No function exported to be used from configuration file.

1.6. Known issues

Due to the fact that OpenSIPS 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 OpenSIPS. 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.

Chapter 2. Developer Guide

2.1. Available Functions

2.1.1.  register_httpdcb (module, root_path, httpd_acces_handler_cb, httpd_flush_data_cb, httpd_init_proc_cb)

Register a new http root with it's associated callbacks into the httpd module.

Meaning of the parameters is as follows:

  • const char *mod - name of the module that register an http root path to be handled;

  • str *root_path - the registered root path;

  • httpd_acces_handler_cb f1 - handler to the callback method to be called on root path match;

  • httpd_flush_data_cb f2 - handler to the callback method to be called for sending extra data (at a later time);

  • httpd_init_proc_cb f3 - handler to the callback method to be called during httpd process init;