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 13:34:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
451348626679c4fe997dfc6f969fd4e4ad022e8c
45134862
1 parent
bfff8413
refine http server, support mount dir for vhost.
隐藏空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
41 行增加
和
2 行删除
trunk/conf/http.server.conf
trunk/src/app/srs_app_http.cpp
trunk/src/app/srs_app_http.hpp
trunk/src/app/srs_app_http_conn.cpp
trunk/conf/http.server.conf
0 → 100644
查看文件 @
4513486
# the config for srs to serve as http server
# @see full.conf for detail config.
listen
1935
;
max_connections
1000
;
http_stream
{
enabled
on
;
listen
8080
;
dir
./
objs
/
nginx
/
html
;
}
vhost
__
defaultVhost__
{
http
{
enabled
on
;
mount
/
default
;
dir
./
objs
/
nginx
/
html
;
}
}
...
...
trunk/src/app/srs_app_http.cpp
查看文件 @
4513486
...
...
@@ -226,6 +226,7 @@ ISrsGoHttpResponseWriter::~ISrsGoHttpResponseWriter()
ISrsGoHttpHandler
::
ISrsGoHttpHandler
()
{
entry
=
NULL
;
}
ISrsGoHttpHandler
::~
ISrsGoHttpHandler
()
...
...
@@ -283,7 +284,16 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
upath
+=
SRS_HTTP_DEFAULT_PAGE
;
}
string
fullpath
=
dir
+
"/"
+
upath
;
string
fullpath
=
dir
+
"/"
;
srs_assert
(
entry
);
if
(
upath
.
length
()
>
entry
->
pattern
.
length
())
{
fullpath
+=
upath
.
substr
(
entry
->
pattern
.
length
());
}
else
{
fullpath
+=
upath
;
}
srs_trace
(
"http match file=%s, pattern=%s, upath=%s"
,
fullpath
.
c_str
(),
entry
->
pattern
.
c_str
(),
upath
.
c_str
());
if
(
srs_string_ends_with
(
fullpath
,
".flv"
)
||
srs_string_ends_with
(
fullpath
,
".fhv"
))
{
std
::
string
start
=
r
->
query_get
(
"start"
);
...
...
@@ -437,6 +447,7 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
entry
->
explicit_match
=
true
;
entry
->
handler
=
handler
;
entry
->
pattern
=
pattern
;
entry
->
handler
->
entry
=
entry
;
if
(
entries
.
find
(
pattern
)
!=
entries
.
end
())
{
SrsGoHttpMuxEntry
*
exists
=
entries
[
pattern
];
...
...
@@ -448,7 +459,7 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
// Helpful behavior:
// If pattern is /tree/, insert an implicit permanent redirect for /tree.
// It can be overridden by an explicit registration.
if
(
!
pattern
.
empty
()
&&
pattern
.
at
(
pattern
.
length
()
-
1
)
==
'/'
)
{
if
(
pattern
!=
"/"
&&
!
pattern
.
empty
()
&&
pattern
.
at
(
pattern
.
length
()
-
1
)
==
'/'
)
{
std
::
string
rpattern
=
pattern
.
substr
(
0
,
pattern
.
length
()
-
1
);
SrsGoHttpMuxEntry
*
entry
=
NULL
;
...
...
@@ -468,6 +479,7 @@ int SrsGoHttpServeMux::handle(std::string pattern, ISrsGoHttpHandler* handler)
entry
->
explicit_match
=
false
;
entry
->
handler
=
new
SrsGoHttpRedirectHandler
(
pattern
,
SRS_CONSTS_HTTP_MovedPermanently
);
entry
->
pattern
=
pattern
;
entry
->
handler
->
entry
=
entry
;
entries
[
rpattern
]
=
entry
;
}
...
...
trunk/src/app/srs_app_http.hpp
查看文件 @
4513486
...
...
@@ -46,6 +46,7 @@ class SrsHttpUri;
class
SrsHttpMessage
;
class
SrsFileReader
;
class
SrsSimpleBuffer
;
class
SrsGoHttpMuxEntry
;
class
ISrsGoHttpResponseWriter
;
// http specification
...
...
@@ -158,6 +159,8 @@ public:
class
ISrsGoHttpHandler
{
public
:
SrsGoHttpMuxEntry
*
entry
;
public
:
ISrsGoHttpHandler
();
virtual
~
ISrsGoHttpHandler
();
public
:
...
...
trunk/src/app/srs_app_http_conn.cpp
查看文件 @
4513486
...
...
@@ -166,6 +166,11 @@ int SrsHttpServer::initialize()
std
::
string
mount
=
_srs_config
->
get_vhost_http_mount
(
vhost
);
std
::
string
dir
=
_srs_config
->
get_vhost_http_dir
(
vhost
);
// the dir mount must always ends with "/"
if
(
mount
!=
"/"
&&
mount
.
rfind
(
"/"
)
!=
mount
.
length
()
-
1
)
{
mount
+=
"/"
;
}
if
((
ret
=
mux
.
handle
(
mount
,
new
SrsVodStream
(
dir
)))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http: mount dir=%s for vhost=%s failed. ret=%d"
,
dir
.
c_str
(),
vhost
.
c_str
(),
ret
);
return
ret
;
...
...
@@ -173,6 +178,7 @@ int SrsHttpServer::initialize()
if
(
mount
==
"/"
)
{
default_root_exists
=
true
;
srs_warn
(
"http: root mount to %s"
,
dir
.
c_str
());
}
}
...
...
@@ -183,6 +189,7 @@ int SrsHttpServer::initialize()
srs_error
(
"http: mount root dir=%s failed. ret=%d"
,
dir
.
c_str
(),
ret
);
return
ret
;
}
srs_trace
(
"http: root mount to %s"
,
dir
.
c_str
());
}
return
ret
;
...
...
请
注册
或
登录
后发表评论