Merge pull request #35 from sergey-dryabzhinsky/new-notify-http-codes-4xx

Add first version of 4xx HTTP code handlers for notify submodule
This commit is contained in:
Sergey 2015-09-17 13:23:56 +03:00
commit bd154e391b

View file

@ -860,6 +860,8 @@ ngx_rtmp_notify_parse_http_retcode(ngx_rtmp_session_t *s,
return NGX_OK;
case (u_char) '3':
return NGX_AGAIN;
case (u_char) '4':
return NGX_DECLINED;
default:
return NGX_ERROR;
}
@ -1005,10 +1007,31 @@ ngx_rtmp_notify_connect_handle(ngx_rtmp_session_t *s,
static ngx_str_t location = ngx_string("location");
rc = ngx_rtmp_notify_parse_http_retcode(s, in);
/* HTTP 5xx or unknown/unsupprted */
if (rc == NGX_ERROR) {
return NGX_ERROR;
}
/* HTTP 4xx */
if (rc == NGX_DECLINED) {
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: connection denyed by callback return code 4xx");
ngx_rtmp_send_status(s, "NetConnection.Connect.Rejected", "error",
"Cennection denyed by notify event handler and callback return code");
// Something by rtmpdump lib
send = ngx_rtmp_send_close_method(s, "close");
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: connect send(e) close method = '%ui'", send == NGX_OK);
return NGX_ERROR;
}
if (rc != NGX_AGAIN) {
goto next;
}
@ -1116,11 +1139,34 @@ ngx_rtmp_notify_publish_handle(ngx_rtmp_session_t *s,
static ngx_str_t location = ngx_string("location");
rc = ngx_rtmp_notify_parse_http_retcode(s, in);
/* HTTP 5xx or unknown/unsupprted */
if (rc == NGX_ERROR) {
ngx_rtmp_notify_clear_flag(s, NGX_RTMP_NOTIFY_PUBLISHING);
return NGX_ERROR;
}
/* HTTP 4xx */
if (rc == NGX_DECLINED) {
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: publishing denyed by callback return code 4xx");
ngx_rtmp_send_status(s, "NetConnection.Connect.Rejected", "error",
"Publishing denyed by notify event handler and callback return code");
ngx_rtmp_notify_clear_flag(s, NGX_RTMP_NOTIFY_PUBLISHING);
// Something by rtmpdump lib
send = ngx_rtmp_send_close_method(s, "close");
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: connect send(e) close method = '%ui'", send == NGX_OK);
return NGX_ERROR;
}
if (rc != NGX_AGAIN) {
goto next;
}
@ -1229,7 +1275,7 @@ ngx_rtmp_notify_play_handle(ngx_rtmp_session_t *s,
void *arg, ngx_chain_t *in)
{
ngx_rtmp_play_t *v = arg;
ngx_int_t rc;
ngx_int_t rc, send;
ngx_str_t local_name;
ngx_rtmp_relay_target_t target;
ngx_url_t *u;
@ -1239,11 +1285,34 @@ ngx_rtmp_notify_play_handle(ngx_rtmp_session_t *s,
static ngx_str_t location = ngx_string("location");
rc = ngx_rtmp_notify_parse_http_retcode(s, in);
/* HTTP 5xx or unknown/unsupprted */
if (rc == NGX_ERROR) {
ngx_rtmp_notify_clear_flag(s, NGX_RTMP_NOTIFY_PLAYING);
return NGX_ERROR;
}
/* HTTP 4xx */
if (rc == NGX_DECLINED) {
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: playing denyed by callback return code 4xx");
ngx_rtmp_send_status(s, "NetConnection.Connect.Rejected", "error",
"Playing denyed by notify event handler and callback return code");
ngx_rtmp_notify_clear_flag(s, NGX_RTMP_NOTIFY_PLAYING);
// Something by rtmpdump lib
send = ngx_rtmp_send_close_method(s, "close");
ngx_log_error(NGX_LOG_INFO, s->connection->log, 0,
"notify: connect send(e) close method = '%ui'", send == NGX_OK);
return NGX_ERROR;
}
if (rc != NGX_AGAIN) {
goto next;
}