mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
parent
664844b5f5
commit
f6661989af
4 changed files with 15 additions and 15 deletions
|
@ -1312,7 +1312,7 @@ SrsHttpApi::SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m
|
|||
: SrsConnection(cm, fd, cip)
|
||||
{
|
||||
mux = m;
|
||||
cros = new SrsHttpCrosMux();
|
||||
cors = new SrsHttpCorsMux();
|
||||
parser = new SrsHttpParser();
|
||||
|
||||
_srs_config->subscribe(this);
|
||||
|
@ -1321,7 +1321,7 @@ SrsHttpApi::SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m
|
|||
SrsHttpApi::~SrsHttpApi()
|
||||
{
|
||||
srs_freep(parser);
|
||||
srs_freep(cros);
|
||||
srs_freep(cors);
|
||||
|
||||
_srs_config->unsubscribe(this);
|
||||
}
|
||||
|
@ -1367,9 +1367,9 @@ int SrsHttpApi::do_cycle()
|
|||
// @see https://github.com/ossrs/srs/issues/398
|
||||
skt.set_recv_timeout(SRS_HTTP_RECV_TIMEOUT_US);
|
||||
|
||||
// initialize the cros, which will proxy to mux.
|
||||
// initialize the cors, which will proxy to mux.
|
||||
bool crossdomain_enabled = _srs_config->get_http_api_crossdomain();
|
||||
if ((ret = cros->initialize(mux, crossdomain_enabled)) != ERROR_SUCCESS) {
|
||||
if ((ret = cors->initialize(mux, crossdomain_enabled)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1425,7 +1425,7 @@ int SrsHttpApi::process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
hm->is_chunked(), hm->is_infinite_chunked());
|
||||
|
||||
// use default server mux to serve http request.
|
||||
if ((ret = cros->serve_http(w, r)) != ERROR_SUCCESS) {
|
||||
if ((ret = cors->serve_http(w, r)) != ERROR_SUCCESS) {
|
||||
if (!srs_is_client_gracefully_close(ret)) {
|
||||
srs_error("serve http msg failed. ret=%d", ret);
|
||||
}
|
||||
|
@ -1440,7 +1440,7 @@ int SrsHttpApi::on_reload_http_api_crossdomain()
|
|||
int ret = ERROR_SUCCESS;
|
||||
|
||||
bool crossdomain_enabled = _srs_config->get_http_api_crossdomain();
|
||||
if ((ret = cros->initialize(mux, crossdomain_enabled)) != ERROR_SUCCESS) {
|
||||
if ((ret = cors->initialize(mux, crossdomain_enabled)) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ class SrsHttpApi : virtual public SrsConnection, virtual public ISrsReloadHandle
|
|||
{
|
||||
private:
|
||||
SrsHttpParser* parser;
|
||||
SrsHttpCrosMux* cros;
|
||||
SrsHttpCorsMux* cors;
|
||||
SrsHttpServeMux* mux;
|
||||
public:
|
||||
SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m, std::string cip);
|
||||
|
|
|
@ -761,18 +761,18 @@ bool SrsHttpServeMux::path_match(string pattern, string path)
|
|||
return false;
|
||||
}
|
||||
|
||||
SrsHttpCrosMux::SrsHttpCrosMux()
|
||||
SrsHttpCorsMux::SrsHttpCorsMux()
|
||||
{
|
||||
next = NULL;
|
||||
enabled = false;
|
||||
required = false;
|
||||
}
|
||||
|
||||
SrsHttpCrosMux::~SrsHttpCrosMux()
|
||||
SrsHttpCorsMux::~SrsHttpCorsMux()
|
||||
{
|
||||
}
|
||||
|
||||
int SrsHttpCrosMux::initialize(ISrsHttpServeMux* worker, bool cros_enabled)
|
||||
int SrsHttpCorsMux::initialize(ISrsHttpServeMux* worker, bool cros_enabled)
|
||||
{
|
||||
next = worker;
|
||||
enabled = cros_enabled;
|
||||
|
@ -780,7 +780,7 @@ int SrsHttpCrosMux::initialize(ISrsHttpServeMux* worker, bool cros_enabled)
|
|||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
int SrsHttpCrosMux::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||
int SrsHttpCorsMux::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||
{
|
||||
// method is OPTIONS and enable crossdomain, required crossdomain header.
|
||||
if (r->is_http_options() && enabled) {
|
||||
|
|
|
@ -443,18 +443,18 @@ private:
|
|||
};
|
||||
|
||||
/**
|
||||
* The filter http mux, directly serve the http CROS requests,
|
||||
* The filter http mux, directly serve the http CORS requests,
|
||||
* while proxy to the worker mux for services.
|
||||
*/
|
||||
class SrsHttpCrosMux : public ISrsHttpServeMux
|
||||
class SrsHttpCorsMux : public ISrsHttpServeMux
|
||||
{
|
||||
private:
|
||||
bool required;
|
||||
bool enabled;
|
||||
ISrsHttpServeMux* next;
|
||||
public:
|
||||
SrsHttpCrosMux();
|
||||
virtual ~SrsHttpCrosMux();
|
||||
SrsHttpCorsMux();
|
||||
virtual ~SrsHttpCorsMux();
|
||||
public:
|
||||
virtual int initialize(ISrsHttpServeMux* worker, bool cros_enabled);
|
||||
// interface ISrsHttpServeMux
|
||||
|
|
Loading…
Reference in a new issue