1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

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

This commit is contained in:
winlin 2015-01-18 17:02:05 +08:00
parent 398b212bfa
commit f1393ee43f
2 changed files with 10 additions and 1 deletions

View file

@ -26,7 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef SRS_AUTO_HTTP_PARSER #ifdef SRS_AUTO_HTTP_PARSER
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h>
using namespace std; using namespace std;
#include <srs_kernel_error.hpp> #include <srs_kernel_error.hpp>
@ -294,6 +294,14 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
} else { } else {
fullpath += upath; 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", srs_trace("http match file=%s, pattern=%s, upath=%s",
fullpath.c_str(), entry->pattern.c_str(), upath.c_str()); fullpath.c_str(), entry->pattern.c_str(), upath.c_str());

View file

@ -265,6 +265,7 @@ public:
class SrsGoHttpServeMux class SrsGoHttpServeMux
{ {
private: private:
// the pattern handler.
std::map<std::string, SrsGoHttpMuxEntry*> entries; std::map<std::string, SrsGoHttpMuxEntry*> entries;
// the vhost handler. // the vhost handler.
std::map<std::string, ISrsGoHttpHandler*> vhosts; std::map<std::string, ISrsGoHttpHandler*> vhosts;