Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2015-01-18 21:04:52 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d546827b1cc1fb0b01f4391f7cf7a090ba9c76a8
d546827b
1 parent
3b853a6d
for #293, refine the mime of content type.
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
40 行增加
和
20 行删除
trunk/src/app/srs_app_http.cpp
trunk/src/app/srs_app_http.cpp
查看文件 @
d546827
...
...
@@ -341,26 +341,46 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
w
->
header
()
->
set_content_length
(
length
);
if
(
srs_string_ends_with
(
fullpath
,
".ts"
))
{
w
->
header
()
->
set_content_type
(
"video/MP2T"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".m3u8"
))
{
w
->
header
()
->
set_content_type
(
"application/x-mpegURL;charset=utf-8"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".flv"
))
{
w
->
header
()
->
set_content_type
(
"video/x-flv"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".xml"
))
{
w
->
header
()
->
set_content_type
(
"text/xml;charset=utf-8"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".js"
))
{
w
->
header
()
->
set_content_type
(
"text/javascript"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".json"
))
{
w
->
header
()
->
set_content_type
(
"application/json;charset=utf-8"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".swf"
))
{
w
->
header
()
->
set_content_type
(
"application/x-shockwave-flash"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".css"
))
{
w
->
header
()
->
set_content_type
(
"text/css;charset=utf-8"
);
}
else
if
(
srs_string_ends_with
(
fullpath
,
".ico"
))
{
w
->
header
()
->
set_content_type
(
"image/x-icon"
);
}
else
{
w
->
header
()
->
set_content_type
(
"text/html;charset=utf-8"
);
static
std
::
map
<
std
::
string
,
std
::
string
>
_mime
;
if
(
_mime
.
empty
())
{
_mime
[
".ts"
]
=
"video/MP2T"
;
_mime
[
".flv"
]
=
"video/x-flv"
;
_mime
[
".m4v"
]
=
"video/x-m4v"
;
_mime
[
".3gpp"
]
=
"video/3gpp"
;
_mime
[
".3gp"
]
=
"video/3gpp"
;
_mime
[
".mp4"
]
=
"video/mp4"
;
_mime
[
".mp3"
]
=
"audio/mpeg"
;
_mime
[
".m4a"
]
=
"audio/x-m4a"
;
_mime
[
".ogg"
]
=
"audio/ogg"
;
_mime
[
".m3u8"
]
=
"application/x-mpegURL;charset=utf-8"
;
_mime
[
".rss"
]
=
"application/rss+xml"
;
_mime
[
".json"
]
=
"application/json;charset=utf-8"
;
_mime
[
".swf"
]
=
"application/x-shockwave-flash"
;
_mime
[
".doc"
]
=
"application/msword"
;
_mime
[
".zip"
]
=
"application/zip"
;
_mime
[
".rar"
]
=
"application/x-rar-compressed"
;
_mime
[
".xml"
]
=
"text/xml;charset=utf-8"
;
_mime
[
".js"
]
=
"text/javascript"
;
_mime
[
".css"
]
=
"text/css;charset=utf-8"
;
_mime
[
".ico"
]
=
"image/x-icon"
;
_mime
[
".png"
]
=
"image/png"
;
_mime
[
".jpeg"
]
=
"image/jpeg"
;
_mime
[
".jpg"
]
=
"image/jpeg"
;
_mime
[
".gif"
]
=
"image/gif"
;
}
if
(
true
)
{
ssize_t
pos
;
std
::
string
ext
=
fullpath
;
if
((
pos
=
ext
.
rfind
(
"."
))
!=
string
::
npos
)
{
ext
=
ext
.
substr
(
pos
);
}
if
(
_mime
.
find
(
ext
)
==
_mime
.
end
())
{
w
->
header
()
->
set_content_type
(
"text/html;charset=utf-8"
);
}
else
{
w
->
header
()
->
set_content_type
(
_mime
[
ext
]);
}
}
// write body.
...
...
请
注册
或
登录
后发表评论