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

Refactor HttpResponseWriter.write, default to single text mode.

This commit is contained in:
winlin 2019-12-17 15:14:59 +08:00
parent 8cdb7cc727
commit d9842b0371
6 changed files with 96 additions and 24 deletions

View file

@ -446,6 +446,9 @@ srs_error_t SrsHttpFileServer::serve_file(ISrsHttpResponseWriter* w, ISrsHttpMes
w->header()->set_content_type(_mime[ext]);
}
}
// Enter chunked mode, because we didn't set the content-length.
w->write_header(SRS_CONSTS_HTTP_OK);
// write body.
int64_t left = length;

View file

@ -150,7 +150,11 @@ public:
// A ResponseWriter interface is used by an HTTP handler to
// construct an HTTP response.
// Usage 1, response with specified length content:
// Usage 0, response with a message once:
// ISrsHttpResponseWriter* w; // create or get response.
// std::string msg = "Hello, HTTP!";
// w->write((char*)msg.data(), (int)msg.length());
// Usage 1, response with specified length content, same to #0:
// ISrsHttpResponseWriter* w; // create or get response.
// std::string msg = "Hello, HTTP!";
// w->header()->set_content_type("text/plain; charset=utf-8");