File: README

package info (click to toggle)
kamailio 4.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 56,100 kB
  • sloc: ansic: 552,832; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (181 lines) | stat: -rw-r--r-- 4,995 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
xHTTP Module

Daniel-Constantin Mierla

   <miconda@gmail.com>

Edited by

Daniel-Constantin Mierla

   <miconda@gmail.com>

Edited by

Alex Balashov

   <abalashov@evaristesys.com>

   Copyright  2010 asipto.com
     __________________________________________________________________

   Table of Contents

   1. Admin Guide

        1. Overview
        2. Note on Latency
        3. Dependencies

              3.1. Kamailio Modules
              3.2. Kamailio Core Settings
              3.3. External Libraries or Applications

        4. Parameters

              4.1. url_skip (str)
              4.2. url_match (str)

        5. Functions

              5.1. xhttp_reply(code, reason, ctype, body)

   List of Examples

   1.1. Set url_skip parameter
   1.2. Set url_match parameter
   1.3. xhttp_reply usage

Chapter 1. Admin Guide

   Table of Contents

   1. Overview
   2. Note on Latency
   3. Dependencies

        3.1. Kamailio Modules
        3.2. Kamailio Core Settings
        3.3. External Libraries or Applications

   4. Parameters

        4.1. url_skip (str)
        4.2. url_match (str)

   5. Functions

        5.1. xhttp_reply(code, reason, ctype, body)

1. Overview

   This module provides basic HTTP/1.0 server functionality inside SIP
   Router. SIP and HTTP are very similar protocols, so, practically, the
   SIP parser can easily handle HTTP requests just by adding a fake Via
   header.

   The xmlrpc module uses the same concept. xHTTP module offers a generic
   HTTP handling way, by calling event_route[xhttp:request] in your
   config. You can check the HTTP URL via config variable $hu. Note that
   use of $ru will raise errors since the structure of an HTTP URL is not
   compatible with that of a SIP URI.

2. Note on Latency

   Because HTTP requests in xhttp are handled by the same, finite number
   of SIP worker processes that operate on SIP messages, the same general
   principles regarding script execution speed and throughput should be
   observed by the writer in event_route[xhttp:request] as in any other
   part of the route script.

   For example, if you initiate a database query in the HTTP request route
   that takes a long time to return rows, the SIP worker process in which
   the request is handled will be blocked for that time and unable to
   process other SIP messages. In most typical installations, there are
   only a few of these worker processes running.

   Therefore, it is highly inadvisable to execute particularly slow things
   in the event_route[xhttp:request], because the request is not handled
   in an asynchronous manner or otherwise peripherally to general SIP
   processing. SIP worker threads will block, pending the outcome of the
   event route just like any other config script route.

   This is no more or less true for xhttp than it is for any other block
   of script in any other scenario, and does not warrant any extraordinary
   concern. It nevertheless bears mention here because some processes with
   embedded HTTP servers have the request processing take place "outside"
   of the main synchronous event sequence, whether by creating separate
   threads or by some other asynchronous handling. That is not the case
   with xhttp.

3. Dependencies

   3.1. Kamailio Modules
   3.2. Kamailio Core Settings
   3.3. External Libraries or Applications

3.1. Kamailio Modules

   The following modules must be loaded before this module:
     * sl - stateless reply.

3.2. Kamailio Core Settings

   SIP requires a Content-Length header for TCP transport. But most HTTP
   clients do not set the content length for normal GET requests.
   Therefore, the core must be configured to allow incoming requests
   without content length header:
     * tcp_accept_no_cl=yes

3.3. External Libraries or Applications

   The following libraries or applications must be installed before
   running Kamailio with this module loaded:
     * None

4. Parameters

   4.1. url_skip (str)
   4.2. url_match (str)

4.1. url_skip (str)

   Regular expression to match the HTTP URL. If there is a match, then
   event route is not executed.

   Default value is null (don't skip).

   Example 1.1. Set url_skip parameter
...
modparam("xhttp", "url_skip", "^/RPC2")
...

4.2. url_match (str)

   Regular expression to match the HTTP URL. If there is no match, then
   event route is not executed. This check is done after url_skip, so if
   both url_skip and url_match would match then the event route is not
   executed (url_skip has higher priority).

   Default value is null (match everything).

   Example 1.2. Set url_match parameter
...
modparam("xhttp", "url_match", "^/sip/")
...

5. Functions

   5.1. xhttp_reply(code, reason, ctype, body)

5.1. xhttp_reply(code, reason, ctype, body)

   Send back a reply with content-type and body.

   Example 1.3. xhttp_reply usage
...
event_route[xhttp:request] {
    xhttp_reply("200", "OK", "text/html",
        "<html><body>OK - [$si:$sp]</body></html>");
}
...