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-02 10:21:04 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
9d34820c80b8de19c6bd5e7d9bdb390ae8a16972
9d34820c
1 parent
8df0f724
fix #158: http-callback check http status code ok(200). 2.0.84
隐藏空白字符变更
内嵌
并排对比
正在显示
10 个修改的文件
包含
88 行增加
和
14 行删除
README.md
trunk/research/api-server/server.py
trunk/src/app/srs_app_heartbeat.cpp
trunk/src/app/srs_app_http.cpp
trunk/src/app/srs_app_http.hpp
trunk/src/app/srs_app_http_client.cpp
trunk/src/app/srs_app_http_client.hpp
trunk/src/app/srs_app_http_hooks.cpp
trunk/src/core/srs_core.hpp
trunk/src/kernel/srs_kernel_error.hpp
README.md
查看文件 @
9d34820
...
...
@@ -501,6 +501,7 @@ Supported operating systems and hardware:
*
2013-10-17, Created.
<br/>
## History
*
v2.0, 2014-01-02, fix
[
#158
](
https://github.com/winlinvip/simple-rtmp-server/issues/158
)
, http-callback check http status code ok(200). 2.0.84
*
v2.0, 2015-01-02, hotfix
[
#216
](
https://github.com/winlinvip/simple-rtmp-server/issues/216
)
, http-callback post in application/json content-type. 2.0.83
*
v2.0, 2014-01-02, fix
[
#263
](
https://github.com/winlinvip/simple-rtmp-server/issues/263
)
, srs-librtmp flv read tag should init size. 2.0.82
*
v2.0, 2015-01-01, hotfix
[
#270
](
https://github.com/winlinvip/simple-rtmp-server/issues/270
)
, memory leak for http client post. 2.0.81
...
...
trunk/research/api-server/server.py
查看文件 @
9d34820
...
...
@@ -87,6 +87,7 @@ class RESTClients(object):
"action": "on_connect",
"client_id": 1985,
"ip": "192.168.1.10", "vhost": "video.test.com", "app": "live",
"tcUrl": "rtmp://video.test.com/live?key=d2fa801d08e3f90ed1e1670e6e52651a",
"pageUrl": "http://www.test.com/live.html"
}
on_close:
...
...
@@ -118,6 +119,7 @@ class RESTClients(object):
action
=
json_req
[
"action"
]
if
action
==
"on_connect"
:
raise
cherrypy
.
HTTPError
(
401
)
code
=
self
.
__on_connect
(
json_req
)
elif
action
==
"on_close"
:
code
=
self
.
__on_close
(
json_req
)
...
...
trunk/src/app/srs_app_heartbeat.cpp
查看文件 @
9d34820
...
...
@@ -75,9 +75,10 @@ void SrsHttpHeartbeat::heartbeat()
ss
<<
__SRS_JOBJECT_END
;
std
::
string
data
=
ss
.
str
();
std
::
string
res
;
int
status_code
;
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
post
(
&
uri
,
data
,
status_code
,
res
))
!=
ERROR_SUCCESS
)
{
srs_info
(
"http post hartbeart uri failed. "
"url=%s, request=%s, response=%s, ret=%d"
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
...
...
@@ -85,8 +86,8 @@ void SrsHttpHeartbeat::heartbeat()
}
srs_info
(
"http hook hartbeart success. "
"url=%s, request=%s, response=%s, ret=%d"
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
"url=%s, request=%s, status_code=%d, response=%s, ret=%d"
,
url
.
c_str
(),
data
.
c_str
(),
status_code
,
res
.
c_str
(),
ret
);
return
;
}
...
...
trunk/src/app/srs_app_http.cpp
查看文件 @
9d34820
...
...
@@ -593,6 +593,11 @@ u_int8_t SrsHttpMessage::method()
return
(
u_int8_t
)
_header
.
method
;
}
u_int16_t
SrsHttpMessage
::
status_code
()
{
return
(
u_int16_t
)
_header
.
status_code
;
}
string
SrsHttpMessage
::
method_str
()
{
if
(
is_http_get
())
{
...
...
trunk/src/app/srs_app_http.hpp
查看文件 @
9d34820
...
...
@@ -249,6 +249,7 @@ public:
public
:
virtual
bool
is_complete
();
virtual
u_int8_t
method
();
virtual
u_int16_t
status_code
();
virtual
std
::
string
method_str
();
virtual
bool
is_http_get
();
virtual
bool
is_http_put
();
...
...
trunk/src/app/srs_app_http_client.cpp
查看文件 @
9d34820
...
...
@@ -52,7 +52,7 @@ SrsHttpClient::~SrsHttpClient()
srs_freep
(
parser
);
}
int
SrsHttpClient
::
post
(
SrsHttpUri
*
uri
,
string
req
,
string
&
res
)
int
SrsHttpClient
::
post
(
SrsHttpUri
*
uri
,
string
req
,
int
&
status_code
,
string
&
res
)
{
res
=
""
;
...
...
@@ -105,6 +105,8 @@ int SrsHttpClient::post(SrsHttpUri* uri, string req, string& res)
srs_assert
(
msg
);
srs_assert
(
msg
->
is_complete
());
status_code
=
(
int
)
msg
->
status_code
();
// get response body.
if
(
msg
->
body_size
()
>
0
)
{
res
=
msg
->
body
();
...
...
trunk/src/app/srs_app_http_client.hpp
查看文件 @
9d34820
...
...
@@ -54,9 +54,10 @@ public:
/**
* to post data to the uri.
* @param req the data post to uri.
* @param res the response data from server.
* @param status_code the output status code response by server.
* @param res output the response data from server.
*/
virtual
int
post
(
SrsHttpUri
*
uri
,
std
::
string
req
,
std
::
string
&
res
);
virtual
int
post
(
SrsHttpUri
*
uri
,
std
::
string
req
,
int
&
status_code
,
std
::
string
&
res
);
private
:
virtual
void
disconnect
();
virtual
int
connect
(
SrsHttpUri
*
uri
);
...
...
trunk/src/app/srs_app_http_hooks.cpp
查看文件 @
9d34820
...
...
@@ -36,7 +36,7 @@ using namespace std;
#include <srs_app_dvr.hpp>
#include <srs_app_http_client.hpp>
#define SRS_HTTP_RESPONSE_OK
"0"
#define SRS_HTTP_RESPONSE_OK
__SRS_XSTR(ERROR_SUCCESS)
#define SRS_HTTP_HEADER_BUFFER 1024
#define SRS_HTTP_BODY_BUFFER 32 * 1024
...
...
@@ -72,15 +72,25 @@ int SrsHttpHooks::on_connect(string url, int client_id, string ip, SrsRequest* r
<<
__SRS_JOBJECT_END
;
std
::
string
data
=
ss
.
str
();
std
::
string
res
;
int
status_code
;
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
post
(
&
uri
,
data
,
status_code
,
res
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http post on_connect uri failed. "
"client_id=%d, url=%s, request=%s, response=%s, ret=%d"
,
client_id
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
ret
;
}
// ensure the http status is ok.
// https://github.com/winlinvip/simple-rtmp-server/issues/158
if
(
status_code
!=
SRS_CONSTS_HTTP_OK
)
{
ret
=
ERROR_HTTP_STATUS_INVLIAD
;
srs_error
(
"http hook on_connect status failed. "
"client_id=%d, code=%d, ret=%d"
,
client_id
,
status_code
,
ret
);
return
ret
;
}
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_error
(
"http hook on_connect validate failed. "
...
...
@@ -117,15 +127,25 @@ void SrsHttpHooks::on_close(string url, int client_id, string ip, SrsRequest* re
<<
__SRS_JOBJECT_END
;
std
::
string
data
=
ss
.
str
();
std
::
string
res
;
int
status_code
;
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
post
(
&
uri
,
data
,
status_code
,
res
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http post on_close uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, ret=%d"
,
client_id
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
;
}
// ensure the http status is ok.
// https://github.com/winlinvip/simple-rtmp-server/issues/158
if
(
status_code
!=
SRS_CONSTS_HTTP_OK
)
{
ret
=
ERROR_HTTP_STATUS_INVLIAD
;
srs_error
(
"http hook on_close status failed. "
"client_id=%d, code=%d, ret=%d"
,
client_id
,
status_code
,
ret
);
return
;
}
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_warn
(
"http hook on_close validate failed, ignored. "
...
...
@@ -163,15 +183,25 @@ int SrsHttpHooks::on_publish(string url, int client_id, string ip, SrsRequest* r
<<
__SRS_JOBJECT_END
;
std
::
string
data
=
ss
.
str
();
std
::
string
res
;
int
status_code
;
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
post
(
&
uri
,
data
,
status_code
,
res
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http post on_publish uri failed. "
"client_id=%d, url=%s, request=%s, response=%s, ret=%d"
,
client_id
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
ret
;
}
// ensure the http status is ok.
// https://github.com/winlinvip/simple-rtmp-server/issues/158
if
(
status_code
!=
SRS_CONSTS_HTTP_OK
)
{
ret
=
ERROR_HTTP_STATUS_INVLIAD
;
srs_error
(
"http hook on_publish status failed. "
"client_id=%d, code=%d, ret=%d"
,
client_id
,
status_code
,
ret
);
return
ret
;
}
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_error
(
"http hook on_publish validate failed. "
...
...
@@ -209,15 +239,25 @@ void SrsHttpHooks::on_unpublish(string url, int client_id, string ip, SrsRequest
<<
__SRS_JOBJECT_END
;
std
::
string
data
=
ss
.
str
();
std
::
string
res
;
int
status_code
;
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
post
(
&
uri
,
data
,
status_code
,
res
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http post on_unpublish uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, ret=%d"
,
client_id
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
;
}
// ensure the http status is ok.
// https://github.com/winlinvip/simple-rtmp-server/issues/158
if
(
status_code
!=
SRS_CONSTS_HTTP_OK
)
{
ret
=
ERROR_HTTP_STATUS_INVLIAD
;
srs_error
(
"http hook on_unpublish status failed. "
"client_id=%d, code=%d, ret=%d"
,
client_id
,
status_code
,
ret
);
return
;
}
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_warn
(
"http hook on_unpublish validate failed, ignored. "
...
...
@@ -255,15 +295,25 @@ int SrsHttpHooks::on_play(string url, int client_id, string ip, SrsRequest* req)
<<
__SRS_JOBJECT_END
;
std
::
string
data
=
ss
.
str
();
std
::
string
res
;
int
status_code
;
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
post
(
&
uri
,
data
,
status_code
,
res
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"http post on_play uri failed. "
"client_id=%d, url=%s, request=%s, response=%s, ret=%d"
,
client_id
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
ret
;
}
// ensure the http status is ok.
// https://github.com/winlinvip/simple-rtmp-server/issues/158
if
(
status_code
!=
SRS_CONSTS_HTTP_OK
)
{
ret
=
ERROR_HTTP_STATUS_INVLIAD
;
srs_error
(
"http hook on_play status failed. "
"client_id=%d, code=%d, ret=%d"
,
client_id
,
status_code
,
ret
);
return
ret
;
}
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_error
(
"http hook on_play validate failed. "
...
...
@@ -301,15 +351,25 @@ void SrsHttpHooks::on_stop(string url, int client_id, string ip, SrsRequest* req
<<
__SRS_JOBJECT_END
;
std
::
string
data
=
ss
.
str
();
std
::
string
res
;
int
status_code
;
SrsHttpClient
http
;
if
((
ret
=
http
.
post
(
&
uri
,
data
,
res
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
http
.
post
(
&
uri
,
data
,
status_code
,
res
))
!=
ERROR_SUCCESS
)
{
srs_warn
(
"http post on_stop uri failed, ignored. "
"client_id=%d, url=%s, request=%s, response=%s, ret=%d"
,
client_id
,
url
.
c_str
(),
data
.
c_str
(),
res
.
c_str
(),
ret
);
return
;
}
// ensure the http status is ok.
// https://github.com/winlinvip/simple-rtmp-server/issues/158
if
(
status_code
!=
SRS_CONSTS_HTTP_OK
)
{
ret
=
ERROR_HTTP_STATUS_INVLIAD
;
srs_error
(
"http hook on_stop status failed. "
"client_id=%d, code=%d, ret=%d"
,
client_id
,
status_code
,
ret
);
return
;
}
if
(
res
.
empty
()
||
res
!=
SRS_HTTP_RESPONSE_OK
)
{
ret
=
ERROR_HTTP_DATA_INVLIAD
;
srs_warn
(
"http hook on_stop validate failed, ignored. "
...
...
trunk/src/core/srs_core.hpp
查看文件 @
9d34820
...
...
@@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 8
3
#define VERSION_REVISION 8
4
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"
...
...
trunk/src/kernel/srs_kernel_error.hpp
查看文件 @
9d34820
...
...
@@ -196,6 +196,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define ERROR_AAC_REQUIRED_ADTS 3046
#define ERROR_AAC_ADTS_HEADER 3047
#define ERROR_AAC_DATA_INVALID 3048
#define ERROR_HTTP_STATUS_INVLIAD 3049
/**
* whether the error code is an system control error.
...
...
请
注册
或
登录
后发表评论