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

refine http stream code.

This commit is contained in:
winlin 2015-01-22 15:05:38 +08:00
parent 7d86c6d9e9
commit dc6299171f

View file

@ -305,7 +305,8 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
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());
// handle file extension. // handle file according to its extension.
// use vod stream for .flv/.fhv
if (srs_string_ends_with(fullpath, ".flv") || srs_string_ends_with(fullpath, ".fhv")) { if (srs_string_ends_with(fullpath, ".flv") || srs_string_ends_with(fullpath, ".fhv")) {
std::string start = r->query_get("start"); std::string start = r->query_get("start");
if (start.empty()) { if (start.empty()) {
@ -318,11 +319,10 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
} }
return serve_flv_stream(w, r, fullpath, offset); return serve_flv_stream(w, r, fullpath, offset);
} else {
return serve_file(w, r, fullpath);
} }
return ret; // serve common static file.
return serve_file(w, r, fullpath);
} }
int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath) int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath)
@ -339,8 +339,8 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
int64_t length = fs.filesize(); int64_t length = fs.filesize();
// unset the content length in chunked encoding. // unset the content length to encode in chunked encoding.
//w->header()->set_content_length(length); w->header()->set_content_length(length);
static std::map<std::string, std::string> _mime; static std::map<std::string, std::string> _mime;
if (_mime.empty()) { if (_mime.empty()) {