Module: sip-router
Branch: master
Commit: 65783f24859f5da45678f2c8a005ca867cc02b86
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=65783f24859f5da45678f2c8a005ca867cc02b86

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date:   Mon Sep 23 19:01:10 2013 +0200

gzcompress: added a small usage example in docs

---

 modules/gzcompress/README                   |   68 ++++++++++++++++++++++++++-
 modules/gzcompress/doc/gzcompress_admin.xml |   68 ++++++++++++++++++++++++++-
 2 files changed, 134 insertions(+), 2 deletions(-)

diff --git a/modules/gzcompress/README b/modules/gzcompress/README
index c3c8e6e..f594c0c 100644
--- a/modules/gzcompress/README
+++ b/modules/gzcompress/README
@@ -33,11 +33,14 @@ Daniel-Constantin Mierla
 
               4.1.
 
+        5. Config File
+
    List of Examples
 
    1.1. Set header_name parameter
    1.2. Set header_value parameter
    1.3. Set sanity_checks parameter
+   1.4. Enable body compression
 
 Chapter 1. Admin Guide
 
@@ -59,11 +62,14 @@ Chapter 1. Admin Guide
 
         4.1.
 
+   5. Config File
+
 1. Overview
 
    This module is able to detect compressed body in received SIP message
    and decompress it as well as compress the body for outgoing SIP
-   message.
+   message. It works also for received HTTP request and replied HTTP
+   response (Kamailio cannot work in HTTP proxy mode).
 
    The decision of whether to do compression or decompression is made by
    detecting a special SIP header (default 'Content-Encoding') that
@@ -160,3 +166,63 @@ modparam("gzcompress", "sanity_checks", 1)
    4.1.
 
    None.
+
+5. Config File
+
+   Next example shows how to enable compression for forwarded requests, as
+   well as replying with compressed body for HTTP requests. For SIP, the
+   request is recevied and forwarded to itself once, just for the sake of
+   showing a simple example.
+
+   Example 1.4. Enable body compression
+...
+
+#!KAMAILIO
+
+debug=3
+memdbg=5
+memlog=5
+
+children=2
+
+log_stderror=yes
+listen=udp:127.0.0.1:5060
+listen=tcp:127.0.0.1:5060
+
+tcp_accept_no_cl=yes
+http_reply_parse=yes
+
+mpath="modules/"
+
+loadmodule "sl.so"
+loadmodule "pv.so"
+loadmodule "xlog.so"
+loadmodule "corex.so"
+loadmodule "textops.so"
+loadmodule "xhttp.so"
+loadmodule "gzcompress.so"
+
+modparam("gzcompress", "header_value", "deflate")
+
+request_route {
+        xlog("received sip request from $si:$sp\r\n");
+
+        if(src_port==5060) {
+                remove_hf("Content-Encoding");
+                $du = "sip:127.0.0.1:9";
+        } else {
+                append_hf("Content-Encoding: gzip\r\n");
+                $du = "sip:127.0.0.1:5060";
+        }
+        forward();
+        exit;
+}
+
+event_route[xhttp:request] {
+        xlog("received http request from $si:$sp\r\n");
+        append_to_reply("Content-Encoding: deflate\r\n");
+    xhttp_reply("200", "OK", "text/html",
+        "<html><body>OK - [$si:$sp]</body></html>");
+}
+
+...
diff --git a/modules/gzcompress/doc/gzcompress_admin.xml 
b/modules/gzcompress/doc/gzcompress_admin.xml
index f7a91b0..5917e7b 100644
--- a/modules/gzcompress/doc/gzcompress_admin.xml
+++ b/modules/gzcompress/doc/gzcompress_admin.xml
@@ -18,7 +18,8 @@
        <para>
                This module is able to detect compressed body in received SIP 
message
                and decompress it as well as compress the body for outgoing SIP
-               message.
+               message. It works also for received HTTP request and replied 
HTTP
+               response (&kamailio; cannot work in HTTP proxy mode).
        </para>
        <para>
                The decision of whether to do compression or decompression is 
made
@@ -161,5 +162,70 @@ modparam("gzcompress", "sanity_checks", 1)
                </para>
        </section>
        </section>
+       <section>
+       <title>Config File</title>
+       <para>
+               Next example shows how to enable compression for forwarded 
requests,
+               as well as replying with compressed body for HTTP requests. For 
SIP,
+               the request is recevied and forwarded to itself once, just for 
the
+               sake of showing a simple example.
+       </para>
+               <example>
+               <title>Enable body compression</title>
+               <programlisting format="linespecific">
+...
+<![CDATA[
+#!KAMAILIO
+
+debug=3
+memdbg=5
+memlog=5
+
+children=2
+
+log_stderror=yes
+listen=udp:127.0.0.1:5060
+listen=tcp:127.0.0.1:5060
+
+tcp_accept_no_cl=yes
+http_reply_parse=yes
+
+mpath="modules/"
+
+loadmodule "sl.so"
+loadmodule "pv.so"
+loadmodule "xlog.so"
+loadmodule "corex.so"
+loadmodule "textops.so"
+loadmodule "xhttp.so"
+loadmodule "gzcompress.so"
+
+modparam("gzcompress", "header_value", "deflate")
+
+request_route {
+       xlog("received sip request from $si:$sp\r\n");
+
+       if(src_port==5060) {
+               remove_hf("Content-Encoding");
+               $du = "sip:127.0.0.1:9";
+       } else {
+               append_hf("Content-Encoding: gzip\r\n");
+               $du = "sip:127.0.0.1:5060";
+       }
+       forward();
+       exit;
+}
+
+event_route[xhttp:request] {
+       xlog("received http request from $si:$sp\r\n");
+       append_to_reply("Content-Encoding: deflate\r\n");
+    xhttp_reply("200", "OK", "text/html",
+        "<html><body>OK - [$si:$sp]</body></html>");
+}
+]]>
+...
+</programlisting>
+               </example>
+       </section>
 </chapter>
 


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to