winlin

refine http stream code.

@@ -305,7 +305,8 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -305,7 +305,8 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
305 srs_trace("http match file=%s, pattern=%s, upath=%s", 305 srs_trace("http match file=%s, pattern=%s, upath=%s",
306 fullpath.c_str(), entry->pattern.c_str(), upath.c_str()); 306 fullpath.c_str(), entry->pattern.c_str(), upath.c_str());
307 307
308 - // handle file extension. 308 + // handle file according to its extension.
  309 + // use vod stream for .flv/.fhv
309 if (srs_string_ends_with(fullpath, ".flv") || srs_string_ends_with(fullpath, ".fhv")) { 310 if (srs_string_ends_with(fullpath, ".flv") || srs_string_ends_with(fullpath, ".fhv")) {
310 std::string start = r->query_get("start"); 311 std::string start = r->query_get("start");
311 if (start.empty()) { 312 if (start.empty()) {
@@ -318,11 +319,10 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -318,11 +319,10 @@ int SrsGoHttpFileServer::serve_http(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
318 } 319 }
319 320
320 return serve_flv_stream(w, r, fullpath, offset); 321 return serve_flv_stream(w, r, fullpath, offset);
321 - } else {  
322 - return serve_file(w, r, fullpath);  
323 } 322 }
324 -  
325 - return ret; 323 +
  324 + // serve common static file.
  325 + return serve_file(w, r, fullpath);
326 } 326 }
327 327
328 int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath) 328 int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* r, string fullpath)
@@ -339,8 +339,8 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage* @@ -339,8 +339,8 @@ int SrsGoHttpFileServer::serve_file(ISrsGoHttpResponseWriter* w, SrsHttpMessage*
339 339
340 int64_t length = fs.filesize(); 340 int64_t length = fs.filesize();
341 341
342 - // unset the content length in chunked encoding.  
343 - //w->header()->set_content_length(length); 342 + // unset the content length to encode in chunked encoding.
  343 + w->header()->set_content_length(length);
344 344
345 static std::map<std::string, std::string> _mime; 345 static std::map<std::string, std::string> _mime;
346 if (_mime.empty()) { 346 if (_mime.empty()) {