mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
extract http static and http stream from http conn.
This commit is contained in:
parent
baa892a762
commit
f8f6e438cc
15 changed files with 2160 additions and 1771 deletions
|
@ -228,6 +228,11 @@ ISrsHttpHandler::~ISrsHttpHandler()
|
|||
{
|
||||
}
|
||||
|
||||
bool ISrsHttpHandler::is_not_found()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SrsHttpRedirectHandler::SrsHttpRedirectHandler(string u, int c)
|
||||
{
|
||||
url = u;
|
||||
|
@ -253,6 +258,11 @@ SrsHttpNotFoundHandler::~SrsHttpNotFoundHandler()
|
|||
{
|
||||
}
|
||||
|
||||
bool SrsHttpNotFoundHandler::is_not_found()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
int SrsHttpNotFoundHandler::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||
{
|
||||
return srs_go_http_error(w, SRS_CONSTS_HTTP_NotFound, SRS_CONSTS_HTTP_NotFound_str);
|
||||
|
@ -487,6 +497,14 @@ ISrsHttpMatchHijacker::~ISrsHttpMatchHijacker()
|
|||
{
|
||||
}
|
||||
|
||||
ISrsHttpServeMux::ISrsHttpServeMux()
|
||||
{
|
||||
}
|
||||
|
||||
ISrsHttpServeMux::~ISrsHttpServeMux()
|
||||
{
|
||||
}
|
||||
|
||||
SrsHttpServeMux::SrsHttpServeMux()
|
||||
{
|
||||
}
|
||||
|
@ -604,6 +622,19 @@ int SrsHttpServeMux::handle(std::string pattern, ISrsHttpHandler* handler)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool SrsHttpServeMux::can_serve(ISrsHttpMessage* r)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
ISrsHttpHandler* h = NULL;
|
||||
if ((ret = find_handler(r, &h)) != ERROR_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
srs_assert(h);
|
||||
return !h->is_not_found();
|
||||
}
|
||||
|
||||
int SrsHttpServeMux::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
@ -654,9 +685,9 @@ int SrsHttpServeMux::find_handler(ISrsHttpMessage* r, ISrsHttpHandler** ph)
|
|||
}
|
||||
}
|
||||
|
||||
static ISrsHttpHandler* h404 = new SrsHttpNotFoundHandler();
|
||||
if (*ph == NULL) {
|
||||
// TODO: FIXME: memory leak.
|
||||
*ph = new SrsHttpNotFoundHandler();
|
||||
*ph = h404;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue