if (stream->max_size == 0 || stream->curr_size < stream->max_size) {
- char *tmp = (char *) pkg_realloc(stream->buf, stream->curr_size + (size * nmemb));
+ char *tmp = (char *) pkg_realloc(stream->buf, stream->curr_size + (size * nmemb));
- if (tmp == NULL) {
- LM_ERR("cannot allocate memory for stream\n");
- return CURLE_WRITE_ERROR;
+ if (tmp == NULL) {
+ LM_ERR("cannot allocate memory for stream\n");
+ return CURLE_WRITE_ERROR;
}
- stream->buf = tmp;
+ stream->buf = tmp;
memcpy(&stream->buf[stream->pos], (char *) ptr, (size * nmemb));
- stream->curr_size += ((size * nmemb));
+ stream->curr_size += ((size * nmemb));
stream->pos += (size * nmemb);
} else {
if(url) {
LM_DBG("We visited URL: %s\n", url);
if (params->pconn) {
- strncpy(params->pconn->redirecturl, url , sizeof(params->pconn->redirecturl));
- }
- }
+ strncpy(params->pconn->redirecturl, url , sizeof(params->pconn->redirecturl));
+ }
+ }
}
if (params->pconn) {
params->pconn->last_result = stat;
curl_easy_cleanup(curl);
}
if (stream.buf != NULL) {
- pkg_free(stream.buf);
+ pkg_free(stream.buf);
}
return stat;
}
if (url && (url->len > 0) && (url->s != NULL)) {
int url_len = conn->schema.len + 3 + conn->url.len + 1 + url->len + 1;
urlbuf = pkg_malloc(url_len);
- if (urlbuf == NULL)
- {
+ if (urlbuf == NULL) {
res = -1;
goto error;
}
} else {
int url_len = conn->schema.len + 3 + conn->url.len + 1;
urlbuf = pkg_malloc(url_len);
- if (urlbuf == NULL)
- {
+ if (urlbuf == NULL) {
res = -1;
goto error;
}
/* Allocated using pkg_memory */
postdata = as_asciiz((str*)post);
if (postdata == NULL) {
- ERR("Curl: No memory left\n");
- res = -1;
- goto error;
- }
+ ERR("Curl: No memory left\n");
+ res = -1;
+ goto error;
+ }
LM_DBG("***** #### ***** CURL POST data: %s Content-type %s\n", postdata, contenttype);
}
{"httpcon", PARAM_STRING|USE_FUNC_PARAM, (void*)curl_con_param},
{"authmetod", PARAM_INT, &default_authmethod },
{"keep_connections", PARAM_INT, &default_keep_connections },
- {0, 0, 0}
+ {0, 0, 0}
};
* \brief Exported Pseudo variables
*/
static pv_export_t mod_pvs[] = {
- {{"curlerror", (sizeof("curlerror")-1)}, /* Curl error codes */
- PVT_OTHER, pv_get_curlerror, 0, pv_parse_curlerror, 0, 0, 0},
+ {{"curlerror", (sizeof("curlerror")-1)}, /* Curl error codes */
+ PVT_OTHER, pv_get_curlerror, 0, pv_parse_curlerror, 0, 0, 0},
- {{0, 0}, 0, 0, 0, 0, 0, 0, 0}
+ {{0, 0}, 0, 0, 0, 0, 0, 0, 0}
};
/* Module interface */
struct module_exports exports = {
- "http_client",
- DEFAULT_DLFLAGS, /* dlopen flags */
- cmds, /* Exported functions */
- params, /* Exported parameters */
- 0, /* exported statistics */
- 0, /* exported MI functions */
- mod_pvs, /* exported pseudo-variables */
- 0, /* extra processes */
- mod_init, /* module initialization function */
- 0, /* response function*/
- destroy, /* destroy function */
- child_init /* per-child init function */
+ "http_client",
+ DEFAULT_DLFLAGS, /* dlopen flags */
+ cmds, /* Exported functions */
+ params, /* Exported parameters */
+ 0, /* exported statistics */
+ 0, /* exported MI functions */
+ mod_pvs, /* exported pseudo-variables */
+ 0, /* extra processes */
+ mod_init, /* module initialization function */
+ 0, /* response function*/
+ destroy, /* destroy function */
+ child_init /* per-child init function */
};
counter_handle_t connections; /* Number of connection definitions */
*/
static int fixup_http_query_get(void** param, int param_no)
{
- if (param_no == 1) {
- return fixup_spve_null(param, 1);
- }
-
- if (param_no == 2) {
- if (fixup_pvar_null(param, 1) != 0) {
- LM_ERR("failed to fixup result pvar\n");
- return -1;
+ if (param_no == 1) {
+ return fixup_spve_null(param, 1);
}
- if (((pv_spec_t *)(*param))->setf == NULL) {
- LM_ERR("result pvar is not writeble\n");
- return -1;
+
+ if (param_no == 2) {
+ if (fixup_pvar_null(param, 1) != 0) {
+ LM_ERR("failed to fixup result pvar\n");
+ return -1;
+ }
+ if (((pv_spec_t *)(*param))->setf == NULL) {
+ LM_ERR("result pvar is not writeble\n");
+ return -1;
+ }
+ return 0;
}
- return 0;
- }
- LM_ERR("invalid parameter number <%d>\n", param_no);
- return -1;
+ LM_ERR("invalid parameter number <%d>\n", param_no);
+ return -1;
}
/*
static int fixup_free_http_query_get(void** param, int param_no)
{
if (param_no == 1) {
- return fixup_free_spve_null(param, 1);
+ return fixup_free_spve_null(param, 1);
}
if (param_no == 2) {
}
/* URL and data may contain pvar */
if (param_no == 2) {
- return fixup_spve_null(param, 1);
+ return fixup_spve_null(param, 1);
}
if (param_no == 3) {
if (fixup_pvar_null(param, 1) != 0) {
}
/* URL and data may contain pvar */
if (param_no == 2 || param_no == 4) {
- return fixup_spve_null(param, 1);
+ return fixup_spve_null(param, 1);
}
if (param_no == 5) {
if (fixup_pvar_null(param, 1) != 0) {
return 0;
}
if (param_no == 2 || param_no == 4) {
- return fixup_free_spve_null(param, 1);
+ return fixup_free_spve_null(param, 1);
}
if (param_no == 5) {
return 0;
}
if (param_no == 2) {
- return fixup_free_spve_null(param, 1);
+ return fixup_free_spve_null(param, 1);
}
if (param_no == 3) {
static int fixup_free_http_query_post(void** param, int param_no)
{
if ((param_no == 1) || (param_no == 2)) {
- return fixup_free_spve_null(param, 1);
+ return fixup_free_spve_null(param, 1);
}
if (param_no == 3) {
*/
static int fixup_free_curl_get_redirect(void** param, int param_no)
{
- if (param_no == 1) {
- /* Char strings don't need freeing */
- return 0;
- }
- if (param_no == 2) {
- return fixup_free_spve_null(param, 1);
- }
+ if (param_no == 1) {
+ /* Char strings don't need freeing */
+ return 0;
+ }
+ if (param_no == 2) {
+ return fixup_free_spve_null(param, 1);
+ }
- LM_ERR("invalid parameter number <%d>\n", param_no);
- return -1;
+ LM_ERR("invalid parameter number <%d>\n", param_no);
+ return -1;
}
/*