mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-25 20:19:36 +00:00
FS-7496 #resolve strip url args after the file extension
This commit is contained in:
parent
b28f7acac1
commit
d29c2d74b6
@ -844,13 +844,14 @@ static const char *find_extension(const char *url)
|
|||||||
* @param extension the filename extension
|
* @param extension the filename extension
|
||||||
* @return the cached URL filename. Free when done.
|
* @return the cached URL filename. Free when done.
|
||||||
*/
|
*/
|
||||||
static char *cached_url_filename_create(url_cache_t *cache, const char *extension)
|
static char *cached_url_filename_create(url_cache_t *cache, const char *url)
|
||||||
{
|
{
|
||||||
char *filename;
|
char *filename;
|
||||||
char *dirname;
|
char *dirname;
|
||||||
char uuid_dir[3] = { 0 };
|
char uuid_dir[3] = { 0 };
|
||||||
switch_uuid_t uuid;
|
switch_uuid_t uuid;
|
||||||
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1] = { 0 };
|
char uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1] = { 0 };
|
||||||
|
const char *extension = find_extension(url);
|
||||||
|
|
||||||
/* filename is constructed from UUID and is stored in cache dir (first 2 characters of UUID) */
|
/* filename is constructed from UUID and is stored in cache dir (first 2 characters of UUID) */
|
||||||
switch_uuid_get(&uuid);
|
switch_uuid_get(&uuid);
|
||||||
@ -862,7 +863,14 @@ static char *cached_url_filename_create(url_cache_t *cache, const char *extensio
|
|||||||
switch_dir_make_recursive(dirname, SWITCH_DEFAULT_DIR_PERMS, cache->pool);
|
switch_dir_make_recursive(dirname, SWITCH_DEFAULT_DIR_PERMS, cache->pool);
|
||||||
|
|
||||||
if (!zstr(extension)) {
|
if (!zstr(extension)) {
|
||||||
|
char *p;
|
||||||
filename = switch_mprintf("%s%s%s.%s", dirname, SWITCH_PATH_SEPARATOR, &uuid_str[2], extension);
|
filename = switch_mprintf("%s%s%s.%s", dirname, SWITCH_PATH_SEPARATOR, &uuid_str[2], extension);
|
||||||
|
if ((p = strchr(filename, '?'))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
|
if ((p = strchr(filename, '#'))) {
|
||||||
|
*p = '\0';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
filename = switch_mprintf("%s%s%s", dirname, SWITCH_PATH_SEPARATOR, &uuid_str[2]);
|
filename = switch_mprintf("%s%s%s", dirname, SWITCH_PATH_SEPARATOR, &uuid_str[2]);
|
||||||
}
|
}
|
||||||
@ -889,7 +897,7 @@ static cached_url_t *cached_url_create(url_cache_t *cache, const char *url, cons
|
|||||||
|
|
||||||
/* intialize cached URL */
|
/* intialize cached URL */
|
||||||
if (zstr(filename)) {
|
if (zstr(filename)) {
|
||||||
u->filename = cached_url_filename_create(cache, find_extension(url));
|
u->filename = cached_url_filename_create(cache, url);
|
||||||
} else {
|
} else {
|
||||||
u->filename = strdup(filename);
|
u->filename = strdup(filename);
|
||||||
}
|
}
|
||||||
@ -1095,7 +1103,7 @@ SWITCH_STANDARD_API(http_cache_prefetch)
|
|||||||
|
|
||||||
#define HTTP_GET_SYNTAX "{param=val}<url>"
|
#define HTTP_GET_SYNTAX "{param=val}<url>"
|
||||||
/**
|
/**
|
||||||
* Get a file from the cache, download if it isn't cached
|
* Get a file from the cache, download if it isn' cached
|
||||||
*/
|
*/
|
||||||
SWITCH_STANDARD_API(http_cache_get)
|
SWITCH_STANDARD_API(http_cache_get)
|
||||||
{
|
{
|
||||||
@ -1564,7 +1572,7 @@ static switch_status_t http_cache_file_open(switch_file_handle_t *handle, const
|
|||||||
file_flags |= SWITCH_FILE_FLAG_WRITE;
|
file_flags |= SWITCH_FILE_FLAG_WRITE;
|
||||||
context->write_url = switch_core_strdup(handle->memory_pool, path);
|
context->write_url = switch_core_strdup(handle->memory_pool, path);
|
||||||
/* allocate local file in cache */
|
/* allocate local file in cache */
|
||||||
context->local_path = cached_url_filename_create(&gcache, find_extension(context->write_url));
|
context->local_path = cached_url_filename_create(&gcache, context->write_url);
|
||||||
} else {
|
} else {
|
||||||
/* READ = HTTP GET */
|
/* READ = HTTP GET */
|
||||||
file_flags |= SWITCH_FILE_FLAG_READ;
|
file_flags |= SWITCH_FILE_FLAG_READ;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user