Browse code

ruxc: added http_reuse modparam

- enable connection reuse

Daniel-Constantin Mierla authored on 24/07/2021 06:16:49
Showing 2 changed files
... ...
@@ -95,6 +95,27 @@ modparam("ruxc", "http_timeout", 2000)
95 95
 ...
96 96
 modparam("ruxc", "http_tlsmode", 1)
97 97
 ...
98
+</programlisting>
99
+		</example>
100
+	</section>
101
+	<section id="ruxc.p.http_reuse">
102
+		<title><varname>http_reuse</varname> (int)</title>
103
+		<para>
104
+		Set to 1 in order to reuse the connection for all requests (each &kamailio;
105
+		process has its own connection). Useful to avoid TCP connect (and TLS
106
+		handshake) when all requests are performed against the same HTTP/S server.
107
+		</para>
108
+		<para>
109
+		<emphasis>
110
+			Default value is 0 (new connection for each request).
111
+		</emphasis>
112
+		</para>
113
+		<example>
114
+		<title>Set <varname>http_reuse</varname> parameter</title>
115
+		<programlisting format="linespecific">
116
+...
117
+modparam("ruxc", "http_reuse", 1)
118
+...
98 119
 </programlisting>
99 120
 		</example>
100 121
 	</section>
... ...
@@ -40,6 +40,7 @@ MODULE_VERSION
40 40
 
41 41
 static int _ruxc_http_timeout = 5000;
42 42
 static int _ruxc_http_tlsmode = 0;
43
+static int _ruxc_http_reuse = 0;
43 44
 
44 45
 static int mod_init(void);
45 46
 static int child_init(int);
... ...
@@ -73,6 +74,7 @@ static cmd_export_t cmds[]={
73 74
 static param_export_t params[]={
74 75
 	{"http_timeout",       PARAM_INT,   &_ruxc_http_timeout},
75 76
 	{"http_tlsmode",       PARAM_INT,   &_ruxc_http_tlsmode},
77
+	{"http_reuse",         PARAM_INT,   &_ruxc_http_reuse},
76 78
 
77 79
 	{0, 0, 0}
78 80
 };
... ...
@@ -132,6 +134,7 @@ static int ki_ruxc_http_get_helper(sip_msg_t *_msg, str *url, str *hdrs,
132 134
     v_http_request.timeout_read = _ruxc_http_timeout;
133 135
     v_http_request.timeout_write = _ruxc_http_timeout;
134 136
 	v_http_request.tlsmode = _ruxc_http_tlsmode;
137
+	v_http_request.reuse = _ruxc_http_reuse;
135 138
 
136 139
 	v_http_request.url = url->s;
137 140
 	v_http_request.url_len = url->len;
... ...
@@ -229,6 +232,7 @@ static int ki_ruxc_http_post_helper(sip_msg_t *_msg, str *url, str *body, str *h
229 232
     v_http_request.timeout_read = _ruxc_http_timeout;
230 233
     v_http_request.timeout_write = _ruxc_http_timeout;
231 234
 	v_http_request.tlsmode = _ruxc_http_tlsmode;
235
+	v_http_request.reuse = _ruxc_http_reuse;
232 236
 
233 237
 	v_http_request.url = url->s;
234 238
 	v_http_request.url_len = url->len;