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-08-21 17:15:32 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
20a8818a8ee88955ef1ee9138dd7dbd08e500235
20a8818a
1 parent
2edcf1d4
refine the error response.
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
15 行增加
和
30 行删除
trunk/src/app/srs_app_http_api.cpp
trunk/src/protocol/srs_http_stack.hpp
trunk/src/app/srs_app_http_api.cpp
查看文件 @
20a8818
...
...
@@ -509,31 +509,23 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
if
(
sid
>=
0
&&
(
stream
=
stat
->
find_stream
(
sid
))
==
NULL
)
{
ret
=
ERROR_RTMP_STREAM_NOT_FOUND
;
srs_error
(
"stream stream_id=%d not found. ret=%d"
,
sid
,
ret
);
ss
<<
SRS_JOBJECT_START
<<
SRS_JFIELD_ERROR
(
ret
)
<<
SRS_JOBJECT_END
;
return
srs_http_response_json
(
w
,
ss
.
str
());
return
srs_http_response_code
(
w
,
ret
);
}
if
(
r
->
is_http_delete
())
{
srs_assert
(
stream
);
SrsSource
*
source
=
SrsSource
::
fetch
(
stream
->
vhost
->
vhost
,
stream
->
app
,
stream
->
stream
);
if
(
source
)
{
source
->
set_expired
();
srs_warn
(
"disconnent stream=%d successfully. vhost=%s, app=%s, stream=%s."
,
sid
,
stream
->
vhost
->
vhost
.
c_str
(),
stream
->
app
.
c_str
(),
stream
->
stream
.
c_str
());
}
else
{
if
(
!
source
)
{
ret
=
ERROR_SOURCE_NOT_FOUND
;
srs_warn
(
"source not found for sid=%d"
,
sid
);
return
srs_http_response_code
(
w
,
ret
);
}
ss
<<
SRS_JOBJECT_START
<<
SRS_JFIELD_ERROR
(
ret
)
<<
SRS_JOBJECT_END
;
return
srs_http_response_json
(
w
,
ss
.
str
());
source
->
set_expired
();
srs_warn
(
"disconnent stream=%d successfully. vhost=%s, app=%s, stream=%s."
,
sid
,
stream
->
vhost
->
vhost
.
c_str
(),
stream
->
app
.
c_str
(),
stream
->
stream
.
c_str
());
return
srs_http_response_code
(
w
,
ret
);
}
else
if
(
r
->
is_http_get
())
{
std
::
stringstream
data
;
...
...
@@ -584,10 +576,7 @@ int SrsGoApiClients::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
if
(
cid
>=
0
&&
(
client
=
stat
->
find_client
(
cid
))
==
NULL
)
{
ret
=
ERROR_RTMP_STREAM_NOT_FOUND
;
srs_error
(
"stream client_id=%d not found. ret=%d"
,
cid
,
ret
);
ss
<<
SRS_JOBJECT_START
<<
SRS_JFIELD_ERROR
(
ret
)
<<
SRS_JOBJECT_END
;
return
srs_http_response_json
(
w
,
ss
.
str
());
return
srs_http_response_code
(
w
,
ret
);
}
...
...
@@ -628,15 +617,7 @@ SrsGoApiError::~SrsGoApiError()
int
SrsGoApiError
::
serve_http
(
ISrsHttpResponseWriter
*
w
,
ISrsHttpMessage
*
r
)
{
std
::
stringstream
ss
;
ss
<<
SRS_JOBJECT_START
<<
SRS_JFIELD_ERROR
(
100
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"msg"
,
"SRS demo error."
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"path"
,
r
->
path
())
<<
SRS_JOBJECT_END
;
return
srs_http_response_json
(
w
,
ss
.
str
());
return
srs_http_response_code
(
w
,
100
);
}
...
...
trunk/src/protocol/srs_http_stack.hpp
查看文件 @
20a8818
...
...
@@ -78,6 +78,10 @@ class ISrsHttpResponseWriter;
// helper function: response in json format.
extern
int
srs_http_response_json
(
ISrsHttpResponseWriter
*
w
,
std
::
string
data
);
/**
* response a typical code object, for example:
* {code : 100}
*/
extern
int
srs_http_response_code
(
ISrsHttpResponseWriter
*
w
,
int
code
);
// get the status text of code.
...
...
请
注册
或
登录
后发表评论