Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d29c2d74
提交
d29c2d74
authored
4月 29, 2015
作者:
Brian West
提交者:
Chris Rienzo
4月 30, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-7496 #resolve strip url args after the file extension
上级
b28f7aca
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
15 行增加
和
7 行删除
+15
-7
mod_http_cache.c
src/mod/applications/mod_http_cache/mod_http_cache.c
+15
-7
没有找到文件。
src/mod/applications/mod_http_cache/mod_http_cache.c
浏览文件 @
d29c2d74
...
@@ -844,14 +844,15 @@ static const char *find_extension(const char *url)
...
@@ -844,14 +844,15 @@ 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
);
switch_uuid_format
(
uuid_str
,
&
uuid
);
switch_uuid_format
(
uuid_str
,
&
uuid
);
...
@@ -861,9 +862,16 @@ static char *cached_url_filename_create(url_cache_t *cache, const char *extensio
...
@@ -861,9 +862,16 @@ static char *cached_url_filename_create(url_cache_t *cache, const char *extensio
/* create sub-directory if it doesn't exist */
/* create sub-directory if it doesn't exist */
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
);
}
else
{
if
((
p
=
strchr
(
filename
,
'?'
)))
{
*
p
=
'\0'
;
}
if
((
p
=
strchr
(
filename
,
'#'
)))
{
*
p
=
'\0'
;
}
}
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
]);
}
}
free
(
dirname
);
free
(
dirname
);
...
@@ -889,7 +897,7 @@ static cached_url_t *cached_url_create(url_cache_t *cache, const char *url, cons
...
@@ -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)
...
@@ -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
...
@@ -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
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论