char *region; // AWS region. Used by AWS S3
switch_time_t expires; // Expiration time in seconds for URL signature. Default is 604800 seconds. Used by AWS S3
switch_size_t bytes_per_block;
-
+ int header_count;
+ char** header_names;
+ char** header_values;
// function to be called to add the profile specific headers to the GET/PUT requests
switch_curl_slist_t *(*append_headers_ptr)(struct http_profile *profile, switch_curl_slist_t *headers,
const char *verb, unsigned int content_length, const char *content_type, const char *url, const unsigned int block_num, char **query_string);
return NULL;
}
+static switch_curl_slist_t *default_append_headers(http_profile_t *profile, switch_curl_slist_t *headers,
+ const char *verb, unsigned int content_length, const char *content_type, const char *url, const unsigned int block_num, char **query_string)
+{
+ char header[1024];
+ int i;
+
+ for (i = 0; i < profile->header_count; i++) {
+ switch_snprintf(header, sizeof(header), "%s: %s", profile->header_names[i], profile->header_values[i]);
+
+ headers = switch_curl_slist_append(headers, header);
+ }
+
+ return headers;
+}
+
+static switch_status_t default_config_profile(switch_xml_t xml, http_profile_t *profile, switch_memory_pool_t *pool)
+{
+ int i, header_count = 0;
+ switch_xml_t header;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Configuring default profile\n");
+
+ for (header = switch_xml_child(xml, "header"); header; header = header->next) {
+ header_count++;
+ }
+
+ profile->header_count = header_count;
+ profile->header_names = switch_core_alloc(pool, sizeof(char*) * header_count);
+ profile->header_values = switch_core_alloc(pool, sizeof(char*) * header_count);
+
+ for (i = 0, header = switch_xml_child(xml, "header"); header; i++, header = header->next) {
+ char *header_name = (char *) switch_xml_attr_soft(header, "name");
+ char *header_value = (char *) switch_xml_txt(header);
+
+ profile->header_names[i] = switch_core_strdup(pool, header_name);
+ profile->header_values[i] = switch_core_strdup(pool, header_value);
+ }
+
+ profile->append_headers_ptr = default_append_headers;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Configured default profile\n");
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
/**
* Configure the module
* @param cache to configure
profile_obj->secret_access_key = NULL;
profile_obj->base_domain = NULL;
profile_obj->bytes_per_block = 0;
+ profile_obj->header_count = 0;
+ profile_obj->header_names = NULL;
+ profile_obj->header_values = NULL;
profile_obj->append_headers_ptr = NULL;
profile_obj->finalise_put_ptr = NULL;
if (azure_blob_config_profile(profile_xml, profile_obj) == SWITCH_STATUS_FALSE) {
continue;
}
+ } else {
+ profile_xml = switch_xml_child(profile, "default");
+ if (profile_xml) {
+ if (default_config_profile(profile_xml, profile_obj, cache->pool) == SWITCH_STATUS_FALSE) {
+ continue;
+ }
+ }
}
}