Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
F
freeswitch
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
张华
freeswitch
Commits
d6c482e4
提交
d6c482e4
authored
6月 20, 2012
作者:
dschreiber
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added support for Content-Type and other optional headers when doing an HTTP PUT
上级
6ea4a5c5
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
1 行删除
+26
-1
mod_http_cache.c
src/mod/applications/mod_http_cache/mod_http_cache.c
+26
-1
没有找到文件。
src/mod/applications/mod_http_cache/mod_http_cache.c
浏览文件 @
d6c482e4
...
...
@@ -24,6 +24,7 @@
* Contributor(s):
*
* Christopher M. Rienzo <chris@rienzo.com>
* Darren Schreiber <d@d-man.org>
*
* Maintainer: Christopher M. Rienzo <chris@rienzo.com>
*
...
...
@@ -190,12 +191,29 @@ static void url_cache_clear(url_cache_t *cache, switch_core_session_t *session);
static
switch_status_t
http_put
(
url_cache_t
*
cache
,
switch_core_session_t
*
session
,
const
char
*
url
,
const
char
*
filename
)
{
switch_status_t
status
=
SWITCH_STATUS_SUCCESS
;
switch_curl_slist_t
*
headers
=
NULL
;
/* optional linked-list of HTTP headers */
char
*
ext
;
/* file extension, used for MIME type identification */
const
char
*
mime_type
=
"application/octet-stream"
;
char
*
buf
;
CURL
*
curl_handle
=
NULL
;
long
httpRes
=
0
;
struct
stat
file_info
=
{
0
};
FILE
*
file_to_put
=
NULL
;
int
fd
;
/* guess what type of mime content this is going to be */
if
((
ext
=
strrchr
(
filename
,
'.'
)))
{
ext
++
;
if
(
!
(
mime_type
=
switch_core_mime_ext2type
(
ext
)))
{
mime_type
=
"application/octet-stream"
;
}
}
buf
=
switch_mprintf
(
"Content-Type: %s"
,
mime_type
);
headers
=
switch_curl_slist_append
(
headers
,
buf
);
/* open file and get the file size */
switch_log_printf
(
SWITCH_CHANNEL_SESSION_LOG
(
session
),
SWITCH_LOG_DEBUG
,
"opening %s for upload to %s
\n
"
,
filename
,
url
);
fd
=
open
(
filename
,
O_RDONLY
);
...
...
@@ -226,6 +244,7 @@ static switch_status_t http_put(url_cache_t *cache, switch_core_session_t *sessi
switch_curl_easy_setopt
(
curl_handle
,
CURLOPT_UPLOAD
,
1
);
switch_curl_easy_setopt
(
curl_handle
,
CURLOPT_PUT
,
1
);
switch_curl_easy_setopt
(
curl_handle
,
CURLOPT_NOSIGNAL
,
1
);
switch_curl_easy_setopt
(
curl_handle
,
CURLOPT_HTTPHEADER
,
headers
);
switch_curl_easy_setopt
(
curl_handle
,
CURLOPT_URL
,
url
);
switch_curl_easy_setopt
(
curl_handle
,
CURLOPT_READDATA
,
file_to_put
);
switch_curl_easy_setopt
(
curl_handle
,
CURLOPT_INFILESIZE_LARGE
,
(
curl_off_t
)
file_info
.
st_size
);
...
...
@@ -260,6 +279,12 @@ done:
fclose
(
file_to_put
);
}
if
(
headers
)
{
switch_curl_slist_free_all
(
headers
);
}
switch_safe_free
(
buf
);
return
status
;
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论