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

Enhance HTTP response write for final_request.

This commit is contained in:
winlin 2019-12-17 19:09:39 +08:00
parent e27cc059e4
commit 81947df819
3 changed files with 107 additions and 3 deletions

View file

@ -619,10 +619,17 @@ SrsHttpResponseWriter::~SrsHttpResponseWriter()
srs_error_t SrsHttpResponseWriter::final_request()
{
srs_error_t err = srs_success;
// write the header data in memory.
if (!header_wrote) {
write_header(SRS_CONSTS_HTTP_OK);
}
// whatever header is wrote, we should try to send header.
if ((err = send_header(NULL, 0)) != srs_success) {
return srs_error_wrap(err, "send header");
}
// complete the chunked encoding.
if (content_length == -1) {
@ -666,7 +673,7 @@ srs_error_t SrsHttpResponseWriter::write(char* data, int size)
}
// ignore NULL content.
if (!data) {
if (!data || size <= 0) {
return err;
}
@ -811,7 +818,7 @@ srs_error_t SrsHttpResponseWriter::send_header(char* data, int size)
// detect content type
if (srs_go_http_body_allowd(status)) {
if (hdr->content_type().empty()) {
if (data && hdr->content_type().empty()) {
hdr->set_content_type(srs_go_http_detect(data, size));
}
}