diff --git a/trunk/src/app/srs_app_caster_flv.cpp b/trunk/src/app/srs_app_caster_flv.cpp index 4de4bb50a7..758e8665d2 100644 --- a/trunk/src/app/srs_app_caster_flv.cpp +++ b/trunk/src/app/srs_app_caster_flv.cpp @@ -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, diff --git a/trunk/src/app/srs_app_caster_flv.hpp b/trunk/src/app/srs_app_caster_flv.hpp index cdba880ee7..ab856c7840 100644 --- a/trunk/src/app/srs_app_caster_flv.hpp +++ b/trunk/src/app/srs_app_caster_flv.hpp @@ -101,6 +101,7 @@ class SrsDynamicHttpConn : virtual public ISrsStartableConneciton, virtual publi 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: diff --git a/trunk/src/app/srs_app_http_api.cpp b/trunk/src/app/srs_app_http_api.cpp index 85a2d48f98..7f23284a08 100644 --- a/trunk/src/app/srs_app_http_api.cpp +++ b/trunk/src/app/srs_app_http_api.cpp @@ -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(); diff --git a/trunk/src/app/srs_app_http_api.hpp b/trunk/src/app/srs_app_http_api.hpp index 7c61bd8031..eeb0973610 100644 --- a/trunk/src/app/srs_app_http_api.hpp +++ b/trunk/src/app/srs_app_http_api.hpp @@ -270,6 +270,7 @@ class SrsHttpApi : virtual public ISrsStartableConneciton, virtual public ISrsHt 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: diff --git a/trunk/src/app/srs_app_http_conn.cpp b/trunk/src/app/srs_app_http_conn.cpp index 47c41f2a8f..9f26e25107 100644 --- a/trunk/src/app/srs_app_http_conn.cpp +++ b/trunk/src/app/srs_app_http_conn.cpp @@ -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, diff --git a/trunk/src/app/srs_app_http_conn.hpp b/trunk/src/app/srs_app_http_conn.hpp index 344eece263..f0f8a34819 100644 --- a/trunk/src/app/srs_app_http_conn.hpp +++ b/trunk/src/app/srs_app_http_conn.hpp @@ -67,6 +67,8 @@ class ISrsHttpConnOwner // 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 @@ class SrsResponseOnlyHttpConn : virtual public ISrsStartableConneciton, virtual 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: