Skip to content

Commit

Permalink
Refine magic number.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jan 1, 2023
1 parent 565f535 commit b0fbbf3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions trunk/src/app/srs_app_http_static.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ srs_error_t SrsHlsStream::serve_m3u8_ctx(ISrsHttpResponseWriter* w, ISrsHttpMess
// Create a m3u8 in memory, contains the session id(ctx).
err = serve_new_session(w, r, req, ctx);
}

// Always make the ctx alive now.
alive(ctx, req);

Expand Down
6 changes: 4 additions & 2 deletions trunk/src/utest/srs_utest_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,12 @@ string mock_http_response3(int status, string content)

string mock_http_response4(int status, string content)
{
string m3u8_header = "#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=1,AVERAGE-BANDWIDTH=1\n";

stringstream ss;
ss << "HTTP/1.1 " << status << " " << srs_generate_http_status_text(status) << "\r\n"
<< "Content-Length: " << content.length() + 58 << "\r\n\r\n"
<< "#EXTM3U\n#EXT-X-STREAM-INF:BANDWIDTH=1,AVERAGE-BANDWIDTH=1\n" // length is 58
<< "Content-Length: " << content.length() + m3u8_header.length() << "\r\n\r\n"
<< m3u8_header
<< content;
return ss.str();
}
Expand Down

0 comments on commit b0fbbf3

Please sign in to comment.