mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #1657, handle on_message_done
This commit is contained in:
parent
4b082ea96c
commit
c3d290013e
6 changed files with 27 additions and 0 deletions
|
@ -269,6 +269,11 @@ srs_error_t SrsDynamicHttpConn::on_http_message(ISrsHttpMessage* r, SrsHttpRespo
|
|||
return srs_success;
|
||||
}
|
||||
|
||||
srs_error_t SrsDynamicHttpConn::on_message_done(ISrsHttpMessage* r, SrsHttpResponseWriter* w)
|
||||
{
|
||||
return srs_success;
|
||||
}
|
||||
|
||||
srs_error_t SrsDynamicHttpConn::on_conn_done(srs_error_t r0)
|
||||
{
|
||||
// Because we use manager to manage this object,
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
public:
|
||||
virtual srs_error_t on_start();
|
||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||
virtual srs_error_t on_message_done(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||
virtual srs_error_t on_conn_done(srs_error_t r0);
|
||||
// Interface ISrsResource.
|
||||
public:
|
||||
|
|
|
@ -1708,6 +1708,13 @@ srs_error_t SrsHttpApi::on_http_message(ISrsHttpMessage* r, SrsHttpResponseWrite
|
|||
//SrsHttpHeader* hdr = w->header();
|
||||
//hdr->set("Connection", "Close");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsHttpApi::on_message_done(ISrsHttpMessage* r, SrsHttpResponseWriter* w)
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
// read all rest bytes in request body.
|
||||
char buf[SRS_HTTP_READ_CACHE_BYTES];
|
||||
ISrsHttpResponseReader* br = r->body_reader();
|
||||
|
|
|
@ -270,6 +270,7 @@ public:
|
|||
public:
|
||||
virtual srs_error_t on_start();
|
||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||
virtual srs_error_t on_message_done(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||
virtual srs_error_t on_conn_done(srs_error_t r0);
|
||||
// Interface ISrsResource.
|
||||
public:
|
||||
|
|
|
@ -209,6 +209,11 @@ srs_error_t SrsHttpConn::do_cycle()
|
|||
if ((err = process_request(&writer, req)) != srs_success) {
|
||||
break;
|
||||
}
|
||||
|
||||
// After the request is processed.
|
||||
if ((err = handler_->on_message_done(req, &writer)) != srs_success) {
|
||||
break;
|
||||
}
|
||||
|
||||
// donot keep alive, disconnect it.
|
||||
// @see https://github.com/ossrs/srs/issues/399
|
||||
|
@ -386,6 +391,11 @@ srs_error_t SrsResponseOnlyHttpConn::on_http_message(ISrsHttpMessage* r, SrsHttp
|
|||
return err;
|
||||
}
|
||||
|
||||
srs_error_t SrsResponseOnlyHttpConn::on_message_done(ISrsHttpMessage* r, SrsHttpResponseWriter* w)
|
||||
{
|
||||
return srs_success;
|
||||
}
|
||||
|
||||
srs_error_t SrsResponseOnlyHttpConn::on_conn_done(srs_error_t r0)
|
||||
{
|
||||
// Because we use manager to manage this object,
|
||||
|
|
|
@ -67,6 +67,8 @@ public:
|
|||
// For the static service or api, discard any body.
|
||||
// For the stream caster, for instance, http flv streaming, may discard the flv header or not.
|
||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w) = 0;
|
||||
// When message is processed, we may need to do more things.
|
||||
virtual srs_error_t on_message_done(ISrsHttpMessage* r, SrsHttpResponseWriter* w) = 0;
|
||||
// When connection is destroy, should use manager to dispose it.
|
||||
// The r0 is the original error, we will use the returned new error.
|
||||
virtual srs_error_t on_conn_done(srs_error_t r0) = 0;
|
||||
|
@ -171,6 +173,7 @@ public:
|
|||
public:
|
||||
virtual srs_error_t on_start();
|
||||
virtual srs_error_t on_http_message(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||
virtual srs_error_t on_message_done(ISrsHttpMessage* r, SrsHttpResponseWriter* w);
|
||||
virtual srs_error_t on_conn_done(srs_error_t r0);
|
||||
// Extract APIs from SrsTcpConnection.
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue