Browse code

http_client: http_client_request (api) content-type header support

- new api call including a content-type argument implemented as new
function - required to resolve geolocation url using POST (#2641)
- Note: not sure if this is the most elegant solution, but it helps
to avoid backward compatibility issues

Wolfgang Kampichler authored on 15/03/2021 13:13:11
Showing 1 changed files
... ...
@@ -52,6 +52,13 @@ int curl_get_redirect(struct sip_msg *_m, const str *connection, str *result);
52 52
 int http_client_query(
53 53
 		struct sip_msg *_m, char *_url, str *_dst, char *_post, char *_hdrs);
54 54
 
55
+/*
56
+ * Performs http_client_query and saves possible result
57
+ * (first body line of reply) to pvar.
58
+ */
59
+int http_client_query_c(
60
+		struct sip_msg *_m, char *_url, str *_dst, char *_post, char *_ctype, char *_hdrs);
61
+
55 62
 /*
56 63
  * Performs http request and saves possible result
57 64
  * (first body line of reply) to pvar.
... ...
@@ -59,7 +66,12 @@ int http_client_query(
59 66
 int http_client_request(
60 67
 		sip_msg_t *_m, char *_url, str *_dst, char *_body, char *_hdrs, char *_met);
61 68
 
62
-
69
+/*
70
+ * Performs http request and saves possible result
71
+ * (first body line of reply) to pvar.
72
+ */
73
+int http_client_request_c(
74
+		sip_msg_t *_m, char *_url, str *_dst, char *_body, char *_ctype, char *_hdrs, char *_met);
63 75
 
64 76
 
65 77
 char *http_get_content_type(const str *connection);
Browse code

http_client: new function http_client_get()

- do explicit GET request with headers (and body)
- exported KSR.http_client.get_hdrs()

Daniel-Constantin Mierla authored on 21/12/2020 09:15:53
Showing 1 changed files
... ...
@@ -52,6 +52,15 @@ int curl_get_redirect(struct sip_msg *_m, const str *connection, str *result);
52 52
 int http_client_query(
53 53
 		struct sip_msg *_m, char *_url, str *_dst, char *_post, char *_hdrs);
54 54
 
55
+/*
56
+ * Performs http request and saves possible result
57
+ * (first body line of reply) to pvar.
58
+ */
59
+int http_client_request(
60
+		sip_msg_t *_m, char *_url, str *_dst, char *_body, char *_hdrs, char *_met);
61
+
62
+
63
+
55 64
 
56 65
 char *http_get_content_type(const str *connection);
57 66
 
Browse code

http_client: clang format the code

Daniel-Constantin Mierla authored on 05/12/2017 14:20:55
Showing 1 changed files
... ...
@@ -37,19 +37,20 @@
37 37
 
38 38
 /*! Use predefined connection to run HTTP get or post
39 39
  */
40
-int curl_con_query_url(struct sip_msg* _m, const str *connection, const str* _url, str* _result, const char *contenttype, const str* _post);
40
+int curl_con_query_url(struct sip_msg *_m, const str *connection,
41
+		const str *_url, str *_result, const char *contenttype,
42
+		const str *_post);
41 43
 
42 44
 /*! Get redirect URL from last connection pkg memory storage */
43
-int curl_get_redirect(struct sip_msg* _m, const str *connection, str* result);
44
-
45
+int curl_get_redirect(struct sip_msg *_m, const str *connection, str *result);
45 46
 
46 47
 
47 48
 /*
48 49
  * Performs http_client_query and saves possible result
49 50
  * (first body line of reply) to pvar.
50 51
  */
51
-int http_client_query(struct sip_msg* _m, char* _url, str* _dst, char* _post,
52
-		char* _hdrs);
52
+int http_client_query(
53
+		struct sip_msg *_m, char *_url, str *_dst, char *_post, char *_hdrs);
53 54
 
54 55
 
55 56
 char *http_get_content_type(const str *connection);
Browse code

http_client: allow providing headers to http_client_query()

- lost from removed http_query() in utils

Daniel-Constantin Mierla authored on 30/06/2017 13:06:24
Showing 1 changed files
... ...
@@ -16,8 +16,8 @@
16 16
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 17
  * GNU General Public License for more details.
18 18
  *
19
- * You should have received a copy of the GNU General Public License 
20
- * along with this program; if not, write to the Free Software 
19
+ * You should have received a copy of the GNU General Public License
20
+ * along with this program; if not, write to the Free Software
21 21
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22 22
  *
23 23
  */
... ...
@@ -44,11 +44,12 @@ int curl_get_redirect(struct sip_msg* _m, const str *connection, str* result);
44 44
 
45 45
 
46 46
 
47
-/* 
48
- * Performs http_query and saves possible result (first body line of reply)
49
- * to pvar.
47
+/*
48
+ * Performs http_client_query and saves possible result
49
+ * (first body line of reply) to pvar.
50 50
  */
51
-int http_query(struct sip_msg* _m, char* _url, str* _dst, char* _post);
51
+int http_client_query(struct sip_msg* _m, char* _url, str* _dst, char* _post,
52
+		char* _hdrs);
52 53
 
53 54
 
54 55
 char *http_get_content_type(const str *connection);
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -33,7 +33,7 @@
33 33
 #ifndef CURL_FUNCTIONS_H
34 34
 #define CURL_FUNCTIONS_H
35 35
 
36
-#include "../../parser/msg_parser.h"
36
+#include "../../core/parser/msg_parser.h"
37 37
 
38 38
 /*! Use predefined connection to run HTTP get or post
39 39
  */
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,56 @@
1
+/*
2
+ * headers of script functions of http_client module
3
+ *
4
+ * Copyright (C) 2008 Juha Heinanen
5
+ * Copyright (C) 2013 Carsten Bock, ng-voice GmbH
6
+ *
7
+ * This file is part of Kamailio, a free SIP server.
8
+ *
9
+ * Kamailio is free software; you can redistribute it and/or modify
10
+ * it under the terms of the GNU General Public License as published by
11
+ * the Free Software Foundation; either version 2 of the License, or
12
+ * (at your option) any later version
13
+ *
14
+ * Kamailio is distributed in the hope that it will be useful,
15
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
+ * GNU General Public License for more details.
18
+ *
19
+ * You should have received a copy of the GNU General Public License 
20
+ * along with this program; if not, write to the Free Software 
21
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
+ *
23
+ */
24
+
25
+/*!
26
+ * \file
27
+ * \brief Kamailio http_client :: script functions include file
28
+ * \ingroup http_client
29
+ * Module: \ref http_client
30
+ */
31
+
32
+
33
+#ifndef CURL_FUNCTIONS_H
34
+#define CURL_FUNCTIONS_H
35
+
36
+#include "../../parser/msg_parser.h"
37
+
38
+/*! Use predefined connection to run HTTP get or post
39
+ */
40
+int curl_con_query_url(struct sip_msg* _m, const str *connection, const str* _url, str* _result, const char *contenttype, const str* _post);
41
+
42
+/*! Get redirect URL from last connection pkg memory storage */
43
+int curl_get_redirect(struct sip_msg* _m, const str *connection, str* result);
44
+
45
+
46
+
47
+/* 
48
+ * Performs http_query and saves possible result (first body line of reply)
49
+ * to pvar.
50
+ */
51
+int http_query(struct sip_msg* _m, char* _url, str* _dst, char* _post);
52
+
53
+
54
+char *http_get_content_type(const str *connection);
55
+
56
+#endif /* CURL_FUNCTIONS_H */