1.2. int http_connection_exists(str *connection)
1.3. http_query(msg, url, dest, post)
+ 1.4. http_get_content_type(str connection)
List of Examples
1.2. int http_connection_exists(str *connection)
1.3. http_query(msg, url, dest, post)
+ 1.4. http_get_content_type(str connection)
1. Available Functions
1.1. http_connect(msg, connection, url, result, content_type, post)
1.2. int http_connection_exists(str *connection)
1.3. http_query(msg, url, dest, post)
+ 1.4. http_get_content_type(str connection)
1.1. http_connect(msg, connection, url, result, content_type, post)
the http_client module and must be freed by the caller.
* const char *post
If not null, the data will be posted to the URL.
+
+1.4. http_get_content_type(str connection)
+
+ Get the content-type of the last result for this connection. This will
+ be something like "text/html" for html or "application/json" for JSON
+ data.
+
+ Result will be a pointer to a char string (char *). This is per
+ process, so the connection will have to be done in the same process.
+ Returns a NULL pointer if the connection does not exist or there's no
+ previous connection data delivered.
/*
* Copyright (C) 2015 Hugh Waite
+ * Copyright (C) 2016 Edvina AB, Olle E. Johansson
*
* This file is part of Kamailio, a free SIP server.
*
api->http_connect = curl_con_query_url;
api->http_query = http_query;
api->http_connection_exists = http_connection_exists;
+ api->http_get_content_type = http_get_content_type;
return 0;
}
typedef int (*httpcapi_httpconnect_f)(struct sip_msg *msg, const str *connection, const str* _url, str* _result, const char *contenttype, const str* _post);
typedef int (*httpcapi_httpquery_f)(struct sip_msg* _m, char* _url, str* _dst, char* _post);
typedef int (*httpcapi_curlcon_exists_f)(str* _name);
+typedef char * (*httpcapi_res_content_type_f)(const str* _name);
typedef struct httpc_api {
httpcapi_httpconnect_f http_connect;
httpcapi_httpquery_f http_query;
httpcapi_curlcon_exists_f http_connection_exists;
+ httpcapi_res_content_type_f http_get_content_type;
} httpc_api_t;
typedef int (*bind_httpc_api_f)(httpc_api_t *api);
</listitem>
</itemizedlist>
</section>
+ <section>
+ <title>
+ <function moreinfo="none">http_get_content_type(str connection)</function>
+ </title>
+ <para>
+ Get the content-type of the last result for this connection. This will
+ be something like "text/html" for html or "application/json" for JSON data.
+ </para>
+ <para>
+ Result will be a pointer to a char string (char *). This is per process,
+ so the connection will have to be done in the same process. Returns a NULL
+ pointer if the connection does not exist or there's no previous connection
+ data delivered.
+ </para>
+ </section>
</section>
return res;
}
+
+
+char *http_get_content_type(const str *connection)
+{
+ curl_con_t *conn = NULL;
+ curl_con_pkg_t *pconn = NULL;
+ str rval;
+
+ /* Find connection if it exists */
+ if (!connection) {
+ LM_ERR("No cURL connection specified\n");
+ return NULL;
+ }
+ LM_DBG("******** CURL Connection %.*s\n", connection->len, connection->s);
+ conn = curl_get_connection((str*)connection);
+ if (conn == NULL) {
+ LM_ERR("No cURL connection found: %.*s\n", connection->len, connection->s);
+ return NULL;
+ }
+ pconn = curl_get_pkg_connection(conn);
+ if (pconn == NULL) {
+ LM_ERR("No cURL connection data found: %.*s\n", connection->len, connection->s);
+ return NULL;
+ }
+
+ return pconn->result_content_type;
+}
int http_query(struct sip_msg* _m, char* _url, str* _dst, char* _post);
+char *http_get_content_type(const str *connection);
+
#endif /* CURL_FUNCTIONS_H */