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

For #1657, refine api for http

This commit is contained in:
winlin 2020-11-06 09:51:04 +08:00
parent 5782b45978
commit 7916214e27
7 changed files with 45 additions and 47 deletions

View file

@ -1674,10 +1674,11 @@ srs_error_t SrsGoApiTcmalloc::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMess
}
#endif
SrsHttpApi::SrsHttpApi(ISrsResourceManager* cm, srs_netfd_t fd, SrsHttpServeMux* m, string cip, int port)
SrsHttpApi::SrsHttpApi(bool https, ISrsResourceManager* cm, srs_netfd_t fd, SrsHttpServeMux* m, string cip, int port)
{
manager = cm;
conn = new SrsHttpConn(this, fd, m, cip, port);
skt = new SrsTcpConnection(fd);
conn = new SrsHttpConn(this, skt, m, cip, port);
_srs_config->subscribe(this);
}
@ -1687,6 +1688,7 @@ SrsHttpApi::~SrsHttpApi()
_srs_config->unsubscribe(this);
srs_freep(conn);
srs_freep(skt);
}
srs_error_t SrsHttpApi::on_start()
@ -1745,6 +1747,9 @@ srs_error_t SrsHttpApi::on_conn_done(srs_error_t r0)
std::string SrsHttpApi::desc()
{
if (ssl) {
return "HttpsConn";
}
return "HttpConn";
}
@ -1768,6 +1773,10 @@ srs_error_t SrsHttpApi::start()
return srs_error_wrap(err, "set cors=%d", v);
}
if ((err = skt->initialize()) != srs_success) {
return srs_error_wrap(err, "init socket");
}
return conn->start();
}