Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
65e20af3
提交
65e20af3
authored
11月 12, 2018
作者:
Christian Schmidt
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
FS-11520: [mod_curl] Make max_bytes configurable
上级
102161e1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
46 行增加
和
3 行删除
+46
-3
curl.conf.xml
conf/vanilla/autoload_configs/curl.conf.xml
+5
-0
curl.conf.xml
...applications/mod_curl/conf/autoload_configs/curl.conf.xml
+5
-0
mod_curl.c
src/mod/applications/mod_curl/mod_curl.c
+36
-3
没有找到文件。
conf/vanilla/autoload_configs/curl.conf.xml
0 → 100644
浏览文件 @
65e20af3
<configuration
name=
"curl.conf"
description=
"cURL module"
>
<settings>
<param
name=
"max-bytes"
value=
"64000"
/>
</settings>
</configuration>
src/mod/applications/mod_curl/conf/autoload_configs/curl.conf.xml
0 → 100644
浏览文件 @
65e20af3
<configuration
name=
"curl.conf"
description=
"cURL module"
>
<settings>
<param
name=
"max-bytes"
value=
"64000"
/>
</settings>
</configuration>
src/mod/applications/mod_curl/mod_curl.c
浏览文件 @
65e20af3
...
...
@@ -55,11 +55,20 @@ static char *SYNTAX = "curl url [headers|json|content-type <mime-type>|connect-t
#define HTTP_SENDFILE_ACK_EVENT "curl_sendfile::ack"
#define HTTP_SENDFILE_RESPONSE_SIZE 32768
#define HTTP_MAX_APPEND_HEADERS 10
#define HTTP_DEFAULT_MAX_BYTES 64000
static
struct
{
switch_memory_pool_t
*
pool
;
switch_event_node_t
*
node
;
int
max_bytes
;
}
globals
;
static
switch_xml_config_item_t
instructions
[]
=
{
/* parameter name type reloadable pointer default value options structure */
SWITCH_CONFIG_ITEM
(
"max-bytes"
,
SWITCH_CONFIG_INT
,
CONFIG_RELOADABLE
,
&
globals
.
max_bytes
,
(
void
*
)
HTTP_DEFAULT_MAX_BYTES
,
NULL
,
NULL
,
NULL
),
SWITCH_CONFIG_ITEM_END
()
};
typedef
enum
{
CSO_NONE
=
(
1
<<
0
),
CSO_EVENT
=
(
1
<<
1
),
...
...
@@ -173,7 +182,7 @@ static http_data_t *do_lookup_url(switch_memory_pool_t *pool, const char *url, c
memset
(
http_data
,
0
,
sizeof
(
http_data_t
));
http_data
->
pool
=
pool
;
http_data
->
max_bytes
=
64000
;
http_data
->
max_bytes
=
globals
.
max_bytes
;
SWITCH_STANDARD_STREAM
(
http_data
->
stream
);
if
(
!
method
)
{
...
...
@@ -1037,24 +1046,44 @@ SWITCH_STANDARD_API(curl_function)
return
status
;
}
static
void
do_config
(
switch_bool_t
reload
)
{
globals
.
max_bytes
=
HTTP_DEFAULT_MAX_BYTES
;
switch_xml_config_parse_module_settings
(
"curl.conf"
,
reload
,
instructions
);
}
static
void
event_handler
(
switch_event_t
*
event
)
{
do_config
(
SWITCH_TRUE
);
}
/* Macro expands to: switch_status_t mod_cidlookup_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
SWITCH_MODULE_LOAD_FUNCTION
(
mod_curl_load
)
{
switch_api_interface_t
*
api_interface
;
switch_application_interface_t
*
app_interface
;
memset
(
&
globals
,
0
,
sizeof
(
globals
));
if
(
switch_event_reserve_subclass
(
HTTP_SENDFILE_ACK_EVENT
)
!=
SWITCH_STATUS_SUCCESS
)
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Couldn't register subclass %s!
\n
"
,
HTTP_SENDFILE_ACK_EVENT
);
return
SWITCH_STATUS_TERM
;
}
if
((
switch_event_bind_removable
(
modname
,
SWITCH_EVENT_RELOADXML
,
NULL
,
event_handler
,
NULL
,
&
globals
.
node
)
!=
SWITCH_STATUS_SUCCESS
))
{
switch_log_printf
(
SWITCH_CHANNEL_LOG
,
SWITCH_LOG_ERROR
,
"Couldn't bind event!
\n
"
);
switch_event_free_subclass
(
HTTP_SENDFILE_ACK_EVENT
);
return
SWITCH_STATUS_TERM
;
}
/* connect my internal structure to the blank pointer passed to me */
*
module_interface
=
switch_loadable_module_create_module_interface
(
pool
,
modname
);
memset
(
&
globals
,
0
,
sizeof
(
globals
));
globals
.
pool
=
pool
;
do_config
(
SWITCH_FALSE
);
SWITCH_ADD_API
(
api_interface
,
"curl"
,
"curl API"
,
curl_function
,
SYNTAX
);
SWITCH_ADD_APP
(
app_interface
,
"curl"
,
"Perform a http request"
,
"Perform a http request"
,
curl_app_function
,
SYNTAX
,
SAF_SUPPORT_NOMEDIA
|
SAF_ROUTING_EXEC
);
...
...
@@ -1074,6 +1103,10 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_curl_shutdown)
switch_event_free_subclass
(
HTTP_SENDFILE_ACK_EVENT
);
switch_xml_config_cleanup
(
instructions
);
switch_event_unbind
(
&
globals
.
node
);
/* Cleanup dynamically allocated config settings */
return
SWITCH_STATUS_SUCCESS
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论