diff --git a/trunk/auto/depends.sh b/trunk/auto/depends.sh index 4d7220586..e312cff9b 100755 --- a/trunk/auto/depends.sh +++ b/trunk/auto/depends.sh @@ -365,6 +365,10 @@ ln -sf `pwd`/research/players ${SRS_OBJS}/nginx/html/players && rm -f ${SRS_OBJS}/nginx/crossdomain.xml && ln -sf `pwd`/research/players/crossdomain.xml ${SRS_OBJS}/nginx/html/crossdomain.xml +# for favicon.ico +rm -rf ${SRS_OBJS}/nginx/html/favicon.ico && +ln -sf `pwd`/research/api-server/static-dir/favicon.ico ${SRS_OBJS}/nginx/html/favicon.ico + # nginx.html to detect whether nginx is alive echo "nginx is ok" > ${SRS_OBJS}/nginx/html/nginx.html diff --git a/trunk/research/api-server/static-dir/favicon.ico b/trunk/research/api-server/static-dir/favicon.ico new file mode 100644 index 000000000..62fd6c026 Binary files /dev/null and b/trunk/research/api-server/static-dir/favicon.ico differ diff --git a/trunk/src/app/srs_app_http.cpp b/trunk/src/app/srs_app_http.cpp index 5d4eb869f..638c70d25 100644 --- a/trunk/src/app/srs_app_http.cpp +++ b/trunk/src/app/srs_app_http.cpp @@ -116,7 +116,7 @@ int SrsHttpHandler::process_request(SrsSocket* skt, SrsHttpMessage* req) return do_process_request(skt, req); } -bool SrsHttpHandler::is_handler_valid(SrsHttpMessage* req, int& status_code, std::string& reason_phrase) +bool SrsHttpHandler::is_handler_valid(SrsHttpMessage* req, int& status_code, string& reason_phrase) { if (!req->match()->unmatched_url.empty()) { status_code = HTTP_NotFound; @@ -203,83 +203,90 @@ int SrsHttpHandler::best_match(const char* path, int length, SrsHttpHandlerMatch return ret; } -SrsHttpHandler* SrsHttpHandler::res_status_line(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_status_line(stringstream& ss) { ss << "HTTP/1.1 200 OK " << __CRLF << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_status_line_error(std::stringstream& ss, int code, std::string reason_phrase) +SrsHttpHandler* SrsHttpHandler::res_status_line_error(stringstream& ss, int code, string reason_phrase) { ss << "HTTP/1.1 " << code << " " << reason_phrase << __CRLF << "Server: SRS/"RTMP_SIG_SRS_VERSION"" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type(stringstream& ss) { ss << "Content-Type: text/html;charset=utf-8" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type_xml(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type_xml(stringstream& ss) { ss << "Content-Type: text/xml;charset=utf-8" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type_javascript(stringstream& ss) { - ss << "Content-Type: text/javascript;charset=utf-8" << __CRLF + ss << "Content-Type: text/javascript" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type_swf(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type_swf(stringstream& ss) { - ss << "Content-Type: application/x-shockwave-flash;charset=utf-8" << __CRLF + ss << "Content-Type: application/x-shockwave-flash" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type_css(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type_css(stringstream& ss) { ss << "Content-Type: text/css;charset=utf-8" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type_json(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type_ico(stringstream& ss) +{ + ss << "Content-Type: image/x-icon" << __CRLF + << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; + return this; +} + +SrsHttpHandler* SrsHttpHandler::res_content_type_json(stringstream& ss) { ss << "Content-Type: application/json;charset=utf-8" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type_m3u8(stringstream& ss) { ss << "Content-Type: application/x-mpegURL;charset=utf-8" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_content_type_mpegts(stringstream& ss) { - ss << "Content-Type: video/MP2T;charset=utf-8" << __CRLF + ss << "Content-Type: video/MP2T" << __CRLF << "Allow: DELETE, GET, HEAD, OPTIONS, POST, PUT" << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_content_length(std::stringstream& ss, int64_t length) +SrsHttpHandler* SrsHttpHandler::res_content_length(stringstream& ss, int64_t length) { ss << "Content-Length: "<< length << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(stringstream& ss) { ss << "Access-Control-Allow-Origin: *" << __CRLF << "Access-Control-Allow-Methods: " @@ -289,19 +296,19 @@ SrsHttpHandler* SrsHttpHandler::res_enable_crossdomain(std::stringstream& ss) return this; } -SrsHttpHandler* SrsHttpHandler::res_header_eof(std::stringstream& ss) +SrsHttpHandler* SrsHttpHandler::res_header_eof(stringstream& ss) { ss << __CRLF; return this; } -SrsHttpHandler* SrsHttpHandler::res_body(std::stringstream& ss, std::string body) +SrsHttpHandler* SrsHttpHandler::res_body(stringstream& ss, string body) { ss << body; return this; } -int SrsHttpHandler::res_flush(SrsSocket* skt, std::stringstream& ss) +int SrsHttpHandler::res_flush(SrsSocket* skt, stringstream& ss) { return skt->write(ss.str().c_str(), ss.str().length(), NULL); } @@ -317,7 +324,7 @@ int SrsHttpHandler::res_options(SrsSocket* skt) return res_flush(skt, ss); } -int SrsHttpHandler::res_text(SrsSocket* skt, SrsHttpMessage* req, std::string body) +int SrsHttpHandler::res_text(SrsSocket* skt, SrsHttpMessage* req, string body) { std::stringstream ss; @@ -334,7 +341,7 @@ int SrsHttpHandler::res_text(SrsSocket* skt, SrsHttpMessage* req, std::string bo return res_flush(skt, ss); } -int SrsHttpHandler::res_xml(SrsSocket* skt, SrsHttpMessage* req, std::string body) +int SrsHttpHandler::res_xml(SrsSocket* skt, SrsHttpMessage* req, string body) { std::stringstream ss; @@ -351,7 +358,7 @@ int SrsHttpHandler::res_xml(SrsSocket* skt, SrsHttpMessage* req, std::string bod return res_flush(skt, ss); } -int SrsHttpHandler::res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::string body) +int SrsHttpHandler::res_javascript(SrsSocket* skt, SrsHttpMessage* req, string body) { std::stringstream ss; @@ -368,7 +375,7 @@ int SrsHttpHandler::res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::str return res_flush(skt, ss); } -int SrsHttpHandler::res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string body) +int SrsHttpHandler::res_swf(SrsSocket* skt, SrsHttpMessage* req, string body) { std::stringstream ss; @@ -385,7 +392,7 @@ int SrsHttpHandler::res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string bod return res_flush(skt, ss); } -int SrsHttpHandler::res_css(SrsSocket* skt, SrsHttpMessage* req, std::string body) +int SrsHttpHandler::res_css(SrsSocket* skt, SrsHttpMessage* req, string body) { std::stringstream ss; @@ -402,7 +409,24 @@ int SrsHttpHandler::res_css(SrsSocket* skt, SrsHttpMessage* req, std::string bod return res_flush(skt, ss); } -int SrsHttpHandler::res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string body) +int SrsHttpHandler::res_ico(SrsSocket* skt, SrsHttpMessage* req, string body) +{ + std::stringstream ss; + + res_status_line(ss)->res_content_type_ico(ss) + ->res_content_length(ss, (int)body.length()); + + if (req->requires_crossdomain()) { + res_enable_crossdomain(ss); + } + + res_header_eof(ss) + ->res_body(ss, body); + + return res_flush(skt, ss); +} + +int SrsHttpHandler::res_m3u8(SrsSocket* skt, SrsHttpMessage* req, string body) { std::stringstream ss; @@ -419,7 +443,7 @@ int SrsHttpHandler::res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string bo return res_flush(skt, ss); } -int SrsHttpHandler::res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string body) +int SrsHttpHandler::res_mpegts(SrsSocket* skt, SrsHttpMessage* req, string body) { std::stringstream ss; @@ -436,7 +460,7 @@ int SrsHttpHandler::res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string return res_flush(skt, ss); } -int SrsHttpHandler::res_json(SrsSocket* skt, SrsHttpMessage* req, std::string json) +int SrsHttpHandler::res_json(SrsSocket* skt, SrsHttpMessage* req, string json) { std::stringstream ss; @@ -453,7 +477,7 @@ int SrsHttpHandler::res_json(SrsSocket* skt, SrsHttpMessage* req, std::string js return res_flush(skt, ss); } -int SrsHttpHandler::res_error(SrsSocket* skt, SrsHttpMessage* req, int code, std::string reason_phrase, std::string body) +int SrsHttpHandler::res_error(SrsSocket* skt, SrsHttpMessage* req, int code, string reason_phrase, string body) { std::stringstream ss; @@ -577,7 +601,7 @@ bool SrsHttpMessage::requires_crossdomain() return _requires_crossdomain; } -void SrsHttpMessage::set_url(std::string url) +void SrsHttpMessage::set_url(string url) { _url = url; } @@ -789,7 +813,7 @@ SrsHttpUri::~SrsHttpUri() { } -int SrsHttpUri::initialize(std::string _url) +int SrsHttpUri::initialize(string _url) { int ret = ERROR_SUCCESS; @@ -856,7 +880,7 @@ const char* SrsHttpUri::get_query() return path.data(); } -std::string SrsHttpUri::get_uri_field(std::string uri, http_parser_url* hp_u, http_parser_url_fields field) +string SrsHttpUri::get_uri_field(string uri, http_parser_url* hp_u, http_parser_url_fields field) { if((hp_u->field_set & (1 << field)) == 0){ return ""; diff --git a/trunk/src/app/srs_app_http.hpp b/trunk/src/app/srs_app_http.hpp index 47453994d..fdce5b179 100644 --- a/trunk/src/app/srs_app_http.hpp +++ b/trunk/src/app/srs_app_http.hpp @@ -237,6 +237,7 @@ public: virtual SrsHttpHandler* res_content_type_javascript(std::stringstream& ss); virtual SrsHttpHandler* res_content_type_swf(std::stringstream& ss); virtual SrsHttpHandler* res_content_type_css(std::stringstream& ss); + virtual SrsHttpHandler* res_content_type_ico(std::stringstream& ss); virtual SrsHttpHandler* res_content_type_json(std::stringstream& ss); virtual SrsHttpHandler* res_content_type_m3u8(std::stringstream& ss); virtual SrsHttpHandler* res_content_type_mpegts(std::stringstream& ss); @@ -252,6 +253,7 @@ public: virtual int res_javascript(SrsSocket* skt, SrsHttpMessage* req, std::string body); virtual int res_swf(SrsSocket* skt, SrsHttpMessage* req, std::string body); virtual int res_css(SrsSocket* skt, SrsHttpMessage* req, std::string body); + virtual int res_ico(SrsSocket* skt, SrsHttpMessage* req, std::string body); virtual int res_m3u8(SrsSocket* skt, SrsHttpMessage* req, std::string body); virtual int res_mpegts(SrsSocket* skt, SrsHttpMessage* req, std::string body); virtual int res_json(SrsSocket* skt, SrsHttpMessage* req, std::string json); diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 0e9dd9200..c5fbfe7f7 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -202,6 +202,8 @@ int SrsHttpVhost::do_process_request(SrsSocket* skt, SrsHttpMessage* req) return res_swf(skt, req, str); } else if (srs_string_ends_with(fullpath, ".css")) { return res_css(skt, req, str); + } else if (srs_string_ends_with(fullpath, ".ico")) { + return res_ico(skt, req, str); } else { return res_text(skt, req, str); } diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index 05fbe5777..f298b8908 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // current release version #define VERSION_MAJOR "0" #define VERSION_MINOR "9" -#define VERSION_REVISION "64" +#define VERSION_REVISION "65" #define RTMP_SIG_SRS_VERSION VERSION_MAJOR"."VERSION_MINOR"."VERSION_REVISION // server info. #define RTMP_SIG_SRS_KEY "srs"