diff --git a/trunk/src/app/srs_app_config.cpp b/trunk/src/app/srs_app_config.cpp index e01e0996ef..d4e6a5cc19 100644 --- a/trunk/src/app/srs_app_config.cpp +++ b/trunk/src/app/srs_app_config.cpp @@ -1615,68 +1615,66 @@ int SrsConfig::global_to_json(SrsAmf0Object* obj) SrsStatisticVhost* svhost = stat->find_vhost(dir->arg0()); sobj->set("id", SrsAmf0Any::number(svhost? (double)svhost->id : 0)); sobj->set("name", dir->dumps_arg0_to_str()); + sobj->set("enabled", SrsAmf0Any::boolean(get_vhost_enabled(dir->arg0()))); - if (get_vhost_enabled(dir->name)) { - sobj->set("enabled", SrsAmf0Any::boolean(true)); - } - if (get_dvr_enabled(dir->name)) { + if (get_dvr_enabled(dir->arg0())) { sobj->set("dvr", SrsAmf0Any::boolean(true)); } - if (get_vhost_http_enabled(dir->name)) { + if (get_vhost_http_enabled(dir->arg0())) { sobj->set("http_static", SrsAmf0Any::boolean(true)); } - if (get_vhost_http_remux_enabled(dir->name)) { + if (get_vhost_http_remux_enabled(dir->arg0())) { sobj->set("http_remux", SrsAmf0Any::boolean(true)); } - if (get_hls_enabled(dir->name)) { + if (get_hls_enabled(dir->arg0())) { sobj->set("hls", SrsAmf0Any::boolean(true)); } - if (get_hds_enabled(dir->name)) { + if (get_hds_enabled(dir->arg0())) { sobj->set("hds", SrsAmf0Any::boolean(true)); } - if (get_vhost_http_hooks(dir->name)) { + if (get_vhost_http_hooks(dir->arg0())) { sobj->set("http_hooks", SrsAmf0Any::boolean(true)); } - if (get_exec_enabled(dir->name)) { + if (get_exec_enabled(dir->arg0())) { sobj->set("exec", SrsAmf0Any::boolean(true)); } - if (get_bw_check_enabled(dir->name)) { + if (get_bw_check_enabled(dir->arg0())) { sobj->set("bandcheck", SrsAmf0Any::boolean(true)); } - if (!get_vhost_is_edge(dir->name)) { + if (!get_vhost_is_edge(dir->arg0())) { sobj->set("origin", SrsAmf0Any::boolean(true)); } - if (get_forward_enabled(dir->name)) { + if (get_forward_enabled(dir->arg0())) { sobj->set("forward", SrsAmf0Any::boolean(true)); } - if (get_security_enabled(dir->name)) { + if (get_security_enabled(dir->arg0())) { sobj->set("security", SrsAmf0Any::boolean(true)); } - if (get_refer_enabled(dir->name)) { + if (get_refer_enabled(dir->arg0())) { sobj->set("refer", SrsAmf0Any::boolean(true)); } - if (get_mr_enabled(dir->name)) { + if (get_mr_enabled(dir->arg0())) { sobj->set("mr", SrsAmf0Any::boolean(true)); } - if (get_realtime_enabled(dir->name)) { + if (get_realtime_enabled(dir->arg0())) { sobj->set("min_latency", SrsAmf0Any::boolean(true)); } - if (get_gop_cache(dir->name)) { + if (get_gop_cache(dir->arg0())) { sobj->set("gop_cache", SrsAmf0Any::boolean(true)); } - if (get_tcp_nodelay(dir->name)) { + if (get_tcp_nodelay(dir->arg0())) { sobj->set("tcp_nodelay", SrsAmf0Any::boolean(true)); } - if (get_mix_correct(dir->name)) { + if (get_mix_correct(dir->arg0())) { sobj->set("mix_correct", SrsAmf0Any::boolean(true)); } - if (get_time_jitter(dir->name) != SrsRtmpJitterAlgorithmOFF) { + if (get_time_jitter(dir->arg0()) != SrsRtmpJitterAlgorithmOFF) { sobj->set("time_jitter", SrsAmf0Any::boolean(true)); } - if (get_atc(dir->name)) { + if (get_atc(dir->arg0())) { sobj->set("atc", SrsAmf0Any::boolean(true)); } diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 2078059acc..9decefbe0b 100755 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -1255,7 +1255,7 @@ int SrsHttpApi::do_cycle() srs_trace("api get peer ip success. ip=%s", ip.c_str()); // initialize parser - if ((ret = parser->initialize(HTTP_REQUEST)) != ERROR_SUCCESS) { + if ((ret = parser->initialize(HTTP_REQUEST, true)) != ERROR_SUCCESS) { srs_error("api initialize http parser failed. ret=%d", ret); return ret; } diff --git a/trunk/src/app/srs_app_http_client.cpp b/trunk/src/app/srs_app_http_client.cpp index fd39cff844..fda78cec5b 100644 --- a/trunk/src/app/srs_app_http_client.cpp +++ b/trunk/src/app/srs_app_http_client.cpp @@ -59,7 +59,7 @@ int SrsHttpClient::initialize(string h, int p, int64_t t_us) srs_freep(parser); parser = new SrsHttpParser(); - if ((ret = parser->initialize(HTTP_RESPONSE)) != ERROR_SUCCESS) { + if ((ret = parser->initialize(HTTP_RESPONSE, false)) != ERROR_SUCCESS) { srs_error("initialize parser failed. ret=%d", ret); return ret; } diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 4824c58618..e812afc423 100755 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -504,7 +504,7 @@ SrsHttpMessage::~SrsHttpMessage() srs_freep(_http_ts_send_buffer); } -int SrsHttpMessage::update(string url, http_parser* header, SrsFastBuffer* body, vector& headers) +int SrsHttpMessage::update(string url, bool allow_jsonp, http_parser* header, SrsFastBuffer* body, vector& headers) { int ret = ERROR_SUCCESS; @@ -572,11 +572,13 @@ int SrsHttpMessage::update(string url, http_parser* header, SrsFastBuffer* body, } // parse jsonp request message. - if (!query_get("callback").empty()) { - jsonp = true; - } - if (jsonp) { - jsonp_method = query_get("method"); + if (allow_jsonp) { + if (!query_get("callback").empty()) { + jsonp = true; + } + if (jsonp) { + jsonp_method = query_get("method"); + } } return ret; @@ -843,10 +845,12 @@ SrsHttpParser::~SrsHttpParser() srs_freep(buffer); } -int SrsHttpParser::initialize(enum http_parser_type type) +int SrsHttpParser::initialize(enum http_parser_type type, bool allow_jsonp) { int ret = ERROR_SUCCESS; + jsonp = allow_jsonp; + memset(&settings, 0, sizeof(settings)); settings.on_message_begin = on_message_begin; settings.on_url = on_url; @@ -891,7 +895,7 @@ int SrsHttpParser::parse_message(SrsStSocket* skt, SrsConnection* conn, ISrsHttp SrsHttpMessage* msg = new SrsHttpMessage(skt, conn); // initalize http msg, parse url. - if ((ret = msg->update(url, &header, buffer, headers)) != ERROR_SUCCESS) { + if ((ret = msg->update(url, jsonp, &header, buffer, headers)) != ERROR_SUCCESS) { srs_error("initialize http msg failed. ret=%d", ret); srs_freep(msg); return ret; @@ -1191,7 +1195,7 @@ int SrsHttpConn::do_cycle() srs_trace("HTTP client ip=%s", ip.c_str()); // initialize parser - if ((ret = parser->initialize(HTTP_REQUEST)) != ERROR_SUCCESS) { + if ((ret = parser->initialize(HTTP_REQUEST, false)) != ERROR_SUCCESS) { srs_error("http initialize http parser failed. ret=%d", ret); return ret; } diff --git a/trunk/src/app/srs_app_http_conn.hpp b/trunk/src/app/srs_app_http_conn.hpp index 4a96f79aeb..829a023e6b 100644 --- a/trunk/src/app/srs_app_http_conn.hpp +++ b/trunk/src/app/srs_app_http_conn.hpp @@ -214,7 +214,7 @@ class SrsHttpMessage : public ISrsHttpMessage /** * set the original messages, then update the message. */ - virtual int update(std::string url, http_parser* header, + virtual int update(std::string url, bool allow_jsonp, http_parser* header, SrsFastBuffer* body, std::vector& headers ); public: @@ -304,6 +304,8 @@ class SrsHttpParser http_parser parser; // the global parse buffer. SrsFastBuffer* buffer; + // whether allow jsonp parse. + bool jsonp; private: // http parse data, reset before parse message. bool expect_field_name; @@ -321,8 +323,9 @@ class SrsHttpParser /** * initialize the http parser with specified type, * one parser can only parse request or response messages. + * @param allow_jsonp whether allow jsonp parser, which indicates the method in query string. */ - virtual int initialize(enum http_parser_type type); + virtual int initialize(enum http_parser_type type, bool allow_jsonp); /** * always parse a http message, * that is, the *ppmsg always NOT-NULL when return success.