Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
6b5313ec
提交
6b5313ec
authored
3月 20, 2017
作者:
Richard Screene
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-10156 [mod_http_cache] Return HTTP status code
上级
9837aa93
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
12 行增加
和
10 行删除
+12
-10
mod_http_cache.c
src/mod/applications/mod_http_cache/mod_http_cache.c
+12
-10
没有找到文件。
src/mod/applications/mod_http_cache/mod_http_cache.c
浏览文件 @
6b5313ec
...
...
@@ -127,7 +127,7 @@ static size_t get_header_callback(void *ptr, size_t size, size_t nmemb, void *ur
static
void
process_cache_control_header
(
cached_url_t
*
url
,
char
*
data
);
static
void
process_content_type_header
(
cached_url_t
*
url
,
char
*
data
);
static
switch_status_t
http_put
(
url_cache_t
*
cache
,
http_profile_t
*
profile
,
switch_core_session_t
*
session
,
const
char
*
url
,
const
char
*
filename
,
int
cache_local_file
);
static
switch_status_t
http_put
(
url_cache_t
*
cache
,
http_profile_t
*
profile
,
switch_core_session_t
*
session
,
const
char
*
url
,
const
char
*
filename
,
int
cache_local_file
,
long
*
httpRes
);
/**
* Queue used for clock cache replacement algorithm. This
...
...
@@ -268,7 +268,7 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *userp)
* @param cache_local_file true if local file should be mapped to url in cache
* @return SWITCH_STATUS_SUCCESS if successful
*/
static
switch_status_t
http_put
(
url_cache_t
*
cache
,
http_profile_t
*
profile
,
switch_core_session_t
*
session
,
const
char
*
url
,
const
char
*
filename
,
int
cache_local_file
)
static
switch_status_t
http_put
(
url_cache_t
*
cache
,
http_profile_t
*
profile
,
switch_core_session_t
*
session
,
const
char
*
url
,
const
char
*
filename
,
int
cache_local_file
,
long
*
httpRes
)
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
...
...
@@ -278,13 +278,13 @@ static switch_status_t http_put(url_cache_t *cache, http_profile_t *profile, swi
char
*
buf
;
CURL
*
curl_handle
=
NULL
;
long
httpRes
=
0
;
struct
stat
file_info
=
{
0
};
FILE
*
file_to_put
=
NULL
;
switch_size_t
sent_bytes
=
0
;
switch_size_t
bytes_per_block
;
unsigned
int
block_num
=
1
;
*
httpRes
=
0
;
/* guess what type of mime content this is going to be */
if
((
ext
=
strrchr
(
filename
,
'.'
)))
{
...
...
@@ -383,13 +383,13 @@ static switch_status_t http_put(url_cache_t *cache, http_profile_t *profile, swi
}
}
switch_curl_easy_perform
(
curl_handle
);
switch_curl_easy_getinfo
(
curl_handle
,
CURLINFO_RESPONSE_CODE
,
&
httpRes
);
switch_curl_easy_getinfo
(
curl_handle
,
CURLINFO_RESPONSE_CODE
,
httpRes
);
switch_curl_easy_cleanup
(
curl_handle
);
if
(
httpRes
==
200
||
httpRes
==
201
||
httpRes
==
202
||
httpRes
==
204
)
{
if
(
*
httpRes
==
200
||
*
httpRes
==
201
||
*
httpRes
==
202
||
*
httpRes
==
204
)
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"%s saved to %s
\n
"
,
filename
,
full_url
);
}
else
{
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Received HTTP error %ld trying to save %s to %s
\n
"
,
httpRes
,
filename
,
url
);
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_ERROR
,
"Received HTTP error %ld trying to save %s to %s
\n
"
,
*
httpRes
,
filename
,
url
);
status
=
SWITCH_STATUS_GENERR
;
}
...
...
@@ -1327,6 +1327,7 @@ SWITCH_STANDARD_API(http_cache_put)
int
argc
=
0
;
switch_event_t
*
params
=
NULL
;
char
*
url
;
long
httpRes
=
0
;
if
(
session
)
{
pool
=
switch_core_session_get_pool
(
session
);
...
...
@@ -1358,11 +1359,11 @@ SWITCH_STANDARD_API(http_cache_put)
profile
=
url_cache_http_profile_find
(
&
gcache
,
switch_event_get_header
(
params
,
"profile"
));
}
status
=
http_put
(
&
gcache
,
profile
,
session
,
url
,
argv
[
1
],
0
);
status
=
http_put
(
&
gcache
,
profile
,
session
,
url
,
argv
[
1
],
0
,
&
httpRes
);
if
(
status
==
SWITCH_STATUS_SUCCESS
)
{
stream
->
write_function
(
stream
,
"+OK
\n
"
);
stream
->
write_function
(
stream
,
"+OK
%ld
\n
"
,
httpRes
);
}
else
{
stream
->
write_function
(
stream
,
"-ERR
\n
"
);
stream
->
write_function
(
stream
,
"-ERR
%ld
\n
"
,
httpRes
);
}
done
:
...
...
@@ -1807,9 +1808,10 @@ static switch_status_t http_file_close(switch_file_handle_t *handle)
{
struct
http_context
*
context
=
(
struct
http_context
*
)
handle
->
private_info
;
switch_status_t
status
=
switch_core_file_close
(
&
context
->
fh
);
long
httpRes
=
0
;
if
(
status
==
SWITCH_STATUS_SUCCESS
&&
!
zstr
(
context
->
write_url
))
{
status
=
http_put
(
&
gcache
,
context
->
profile
,
NULL
,
context
->
write_url
,
context
->
local_path
,
1
);
status
=
http_put
(
&
gcache
,
context
->
profile
,
NULL
,
context
->
write_url
,
context
->
local_path
,
1
,
&
httpRes
);
}
if
(
!
zstr
(
context
->
write_url
))
{
switch_safe_free
(
context
->
local_path
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论