char *data = NULL;
switch_curl_slist_t *headers = NULL;
char *url = NULL;
- char *dynamic_url = NULL;
+ char *dynamic_url = NULL, *use_url = NULL;
const char *session_id = NULL;
switch_status_t status = SWITCH_STATUS_FALSE;
int get_style_method = 0;
switch_event_t *save_params = NULL;
const char *put_file;
FILE *fd = NULL;
-
+ char *creds, *dup_creds = NULL;
+
if (client->one_time_params && client->one_time_params->headers) {
save_params = client->params;
switch_event_dup(&client->params, save_params);
}
}
+
+ if ((use_url = strchr(dynamic_url, '@'))) {
+ char *r, *q, *p = strstr(dynamic_url, "://");
+ use_url++;
+
+ dup_creds = strdup(p+3);
+
+ if ((q = strchr(dup_creds, '@'))) *q = '\0';
+
+ q = strdup(url);
+ r = strchr(q, '@');
+ r++;
+
+ if ((p = strstr(q, "://"))) {
+ *(p+3) = '\0';
+ }
+
+ p = switch_mprintf("%s%s", q, r);
+ free(dynamic_url);
+ dynamic_url = p;
+ free(q);
+ }
+
+
+ if ((use_url = strchr(dynamic_url, '@'))) {
+ char *q, *p = strstr(dynamic_url, "://");
+ use_url++;
+
+ dup_creds = strdup(p+3);
+ *p = '\0';
+
+ if ((q = strchr(dup_creds, '@'))) *q = '\0';
+
+ creds = dup_creds;
+
+ p = switch_mprintf("%s%s", p, use_url);
+ free(dynamic_url);
+ dynamic_url = p;
+ } else {
+ creds = client->profile->cred;
+ }
+
curl_handle = switch_curl_easy_init();
if (session_id) {
}
- if (!zstr(client->profile->cred)) {
+ if (!zstr(creds)) {
switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, client->profile->auth_scheme);
- switch_curl_easy_setopt(curl_handle, CURLOPT_USERPWD, client->profile->cred);
+ switch_curl_easy_setopt(curl_handle, CURLOPT_USERPWD, creds);
}
if (client->profile->disable100continue) {
curl_easy_setopt(curl_handle, CURLOPT_INTERFACE, client->profile->bind_local);
}
+ switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "mod_httapi/1.0");
switch_curl_easy_perform(curl_handle);
switch_curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &client->code);
switch_curl_easy_cleanup(curl_handle);
}
switch_safe_free(data);
+ switch_safe_free(dup_creds);
if (dynamic_url != url) {
switch_safe_free(dynamic_url);
client_t client = { 0 };
long code;
switch_status_t status = SWITCH_STATUS_FALSE;
-
+ char *dup_creds = NULL, *dynamic_url = NULL, *use_url;
client.fd = -1;
if (save_path) {
}
}
+
+ if ((use_url = strchr(url, '@'))) {
+ char *r, *q, *p = strstr(url, "://");
+ use_url++;
+
+ dup_creds = strdup(p+3);
+
+ if ((q = strchr(dup_creds, '@'))) *q = '\0';
+
+ q = strdup(url);
+ r = strchr(q, '@');
+ r++;
+
+ if ((p = strstr(q, "://"))) {
+ *(p+3) = '\0';
+ }
+
+ p = switch_mprintf("%s%s", q, r);
+ dynamic_url = p;
+ free(q);
+ url = dynamic_url;
+ }
+
curl_handle = switch_curl_easy_init();
switch_curl_easy_setopt(curl_handle, CURLOPT_NOSIGNAL, 1);
switch_curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *) &client);
}
}
+
+ if (!zstr(dup_creds)) {
+ switch_curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
+ switch_curl_easy_setopt(curl_handle, CURLOPT_USERPWD, dup_creds);
+ }
switch_curl_easy_setopt(curl_handle, CURLOPT_USERAGENT, "mod_httapi/1.0");
switch_curl_easy_perform(curl_handle);
break;
}
+ switch_safe_free(dynamic_url);
+ switch_safe_free(dup_creds);
+
return status;
}