mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #1657, Support HTTPS API
This commit is contained in:
parent
7916214e27
commit
272ca9d0f6
20 changed files with 647 additions and 11 deletions
|
@ -1678,7 +1678,14 @@ SrsHttpApi::SrsHttpApi(bool https, ISrsResourceManager* cm, srs_netfd_t fd, SrsH
|
|||
{
|
||||
manager = cm;
|
||||
skt = new SrsTcpConnection(fd);
|
||||
conn = new SrsHttpConn(this, skt, m, cip, port);
|
||||
|
||||
if (https) {
|
||||
ssl = new SrsSslConnection(skt);
|
||||
conn = new SrsHttpConn(this, ssl, m, cip, port);
|
||||
} else {
|
||||
ssl = NULL;
|
||||
conn = new SrsHttpConn(this, skt, m, cip, port);
|
||||
}
|
||||
|
||||
_srs_config->subscribe(this);
|
||||
}
|
||||
|
@ -1688,6 +1695,7 @@ SrsHttpApi::~SrsHttpApi()
|
|||
_srs_config->unsubscribe(this);
|
||||
|
||||
srs_freep(conn);
|
||||
srs_freep(ssl);
|
||||
srs_freep(skt);
|
||||
}
|
||||
|
||||
|
@ -1695,6 +1703,10 @@ srs_error_t SrsHttpApi::on_start()
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
if (ssl && (err = ssl->handshake()) != srs_success) {
|
||||
return srs_error_wrap(err, "handshake");
|
||||
}
|
||||
|
||||
if ((err = conn->set_jsonp(true)) != srs_success) {
|
||||
return srs_error_wrap(err, "set jsonp");
|
||||
}
|
||||
|
@ -1706,6 +1718,12 @@ srs_error_t SrsHttpApi::on_http_message(ISrsHttpMessage* r, SrsHttpResponseWrite
|
|||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// After parsed the message, set the schema to https.
|
||||
if (ssl) {
|
||||
SrsHttpMessage* hm = dynamic_cast<SrsHttpMessage*>(r);
|
||||
hm->set_https(true);
|
||||
}
|
||||
|
||||
// TODO: For each API session, we use short-term HTTP connection.
|
||||
//SrsHttpHeader* hdr = w->header();
|
||||
//hdr->set("Connection", "Close");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue