From f1393ee43fb7e5397ca1c8b343b8d290bcae6c65 Mon Sep 17 00:00:00 2001 From: winlin Date: Sun, 18 Jan 2015 17:02:05 +0800 Subject: [PATCH] for bug #277, use http not found when no file. --- trunk/src/app/srs_app_http.cpp | 10 +++++++++- trunk/src/app/srs_app_http.hpp | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/trunk/src/app/srs_app_http.cpp b/trunk/src/app/srs_app_http.cpp index c5014ce0d..91a48763c 100644 --- a/trunk/src/app/srs_app_http.cpp +++ b/trunk/src/app/srs_app_http.cpp @@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef SRS_AUTO_HTTP_PARSER #include - +#include using namespace std; #include @@ -294,6 +294,14 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* } else { fullpath += upath; } + + // stat current dir, if exists, return error. + struct stat st; + if (stat(fullpath.c_str(), &st) != 0) { + srs_warn("http miss file=%s, pattern=%s, upath=%s", + fullpath.c_str(), entry->pattern.c_str(), upath.c_str()); + return SrsGoHttpNotFoundHandler().serve_http(w, r); + } srs_trace("http match file=%s, pattern=%s, upath=%s", fullpath.c_str(), entry->pattern.c_str(), upath.c_str()); diff --git a/trunk/src/app/srs_app_http.hpp b/trunk/src/app/srs_app_http.hpp index df8906834..2a39bec69 100644 --- a/trunk/src/app/srs_app_http.hpp +++ b/trunk/src/app/srs_app_http.hpp @@ -265,6 +265,7 @@ public: class SrsGoHttpServeMux { private: + // the pattern handler. std::map entries; // the vhost handler. std::map vhosts;