winlin

for bug #277, use http not found when no file.

@@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 #ifdef SRS_AUTO_HTTP_PARSER 26 #ifdef SRS_AUTO_HTTP_PARSER
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 - 29 +#include <sys/stat.h>
30 using namespace std; 30 using namespace std;
31 31
32 #include <srs_kernel_error.hpp> 32 #include <srs_kernel_error.hpp>
@@ -294,6 +294,14 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -294,6 +294,14 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
294 } else { 294 } else {
295 fullpath += upath; 295 fullpath += upath;
296 } 296 }
  297 +
  298 + // stat current dir, if exists, return error.
  299 + struct stat st;
  300 + if (stat(fullpath.c_str(), &st) != 0) {
  301 + srs_warn("http miss file=%s, pattern=%s, upath=%s",
  302 + fullpath.c_str(), entry->pattern.c_str(), upath.c_str());
  303 + return SrsGoHttpNotFoundHandler().serve_http(w, r);
  304 + }
297 srs_trace("http match file=%s, pattern=%s, upath=%s", 305 srs_trace("http match file=%s, pattern=%s, upath=%s",
298 fullpath.c_str(), entry->pattern.c_str(), upath.c_str()); 306 fullpath.c_str(), entry->pattern.c_str(), upath.c_str());
299 307
@@ -265,6 +265,7 @@ public: @@ -265,6 +265,7 @@ public:
265 class SrsGoHttpServeMux 265 class SrsGoHttpServeMux
266 { 266 {
267 private: 267 private:
  268 + // the pattern handler.
268 std::map<std::string, SrsGoHttpMuxEntry*> entries; 269 std::map<std::string, SrsGoHttpMuxEntry*> entries;
269 // the vhost handler. 270 // the vhost handler.
270 std::map<std::string, ISrsGoHttpHandler*> vhosts; 271 std::map<std::string, ISrsGoHttpHandler*> vhosts;