mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
fix #399, disconnect when not keep alive.
This commit is contained in:
parent
46a81372e7
commit
c17a1198cb
4 changed files with 30 additions and 0 deletions
|
@ -1082,6 +1082,7 @@ SrsHttpMessage::SrsHttpMessage(SrsStSocket* io, SrsConnection* c)
|
||||||
{
|
{
|
||||||
conn = c;
|
conn = c;
|
||||||
chunked = false;
|
chunked = false;
|
||||||
|
keep_alive = true;
|
||||||
_uri = new SrsHttpUri();
|
_uri = new SrsHttpUri();
|
||||||
_body = new SrsHttpResponseReader(this, io);
|
_body = new SrsHttpResponseReader(this, io);
|
||||||
_http_ts_send_buffer = new char[SRS_HTTP_TS_SEND_BUFFER_SIZE];
|
_http_ts_send_buffer = new char[SRS_HTTP_TS_SEND_BUFFER_SIZE];
|
||||||
|
@ -1106,6 +1107,9 @@ int SrsHttpMessage::update(string url, http_parser* header, SrsFastBuffer* body,
|
||||||
std::string transfer_encoding = get_request_header("Transfer-Encoding");
|
std::string transfer_encoding = get_request_header("Transfer-Encoding");
|
||||||
chunked = (transfer_encoding == "chunked");
|
chunked = (transfer_encoding == "chunked");
|
||||||
|
|
||||||
|
// whether keep alive.
|
||||||
|
keep_alive = http_should_keep_alive(header);
|
||||||
|
|
||||||
// set the buffer.
|
// set the buffer.
|
||||||
if ((ret = _body->initialize(body)) != ERROR_SUCCESS) {
|
if ((ret = _body->initialize(body)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -1232,6 +1236,11 @@ bool SrsHttpMessage::is_chunked()
|
||||||
return chunked;
|
return chunked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SrsHttpMessage::is_keep_alive()
|
||||||
|
{
|
||||||
|
return keep_alive;
|
||||||
|
}
|
||||||
|
|
||||||
string SrsHttpMessage::uri()
|
string SrsHttpMessage::uri()
|
||||||
{
|
{
|
||||||
std::string uri = _uri->get_schema();
|
std::string uri = _uri->get_schema();
|
||||||
|
|
|
@ -494,6 +494,11 @@ private:
|
||||||
* whether the body is chunked.
|
* whether the body is chunked.
|
||||||
*/
|
*/
|
||||||
bool chunked;
|
bool chunked;
|
||||||
|
/**
|
||||||
|
* whether the request indicates should keep alive
|
||||||
|
* for the http connection.
|
||||||
|
*/
|
||||||
|
bool keep_alive;
|
||||||
/**
|
/**
|
||||||
* uri parser
|
* uri parser
|
||||||
*/
|
*/
|
||||||
|
@ -538,6 +543,10 @@ public:
|
||||||
* whether body is chunked encoding, for reader only.
|
* whether body is chunked encoding, for reader only.
|
||||||
*/
|
*/
|
||||||
virtual bool is_chunked();
|
virtual bool is_chunked();
|
||||||
|
/**
|
||||||
|
* whether should keep the connection alive.
|
||||||
|
*/
|
||||||
|
virtual bool is_keep_alive();
|
||||||
/**
|
/**
|
||||||
* the uri contains the host and path.
|
* the uri contains the host and path.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -555,6 +555,12 @@ int SrsHttpApi::do_cycle()
|
||||||
if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) {
|
if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// donot keep alive, disconnect it.
|
||||||
|
// @see https://github.com/simple-rtmp-server/srs/issues/399
|
||||||
|
if (!req->is_keep_alive()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -1412,6 +1412,12 @@ int SrsHttpConn::do_cycle()
|
||||||
if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) {
|
if ((ret = process_request(&writer, req)) != ERROR_SUCCESS) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// donot keep alive, disconnect it.
|
||||||
|
// @see https://github.com/simple-rtmp-server/srs/issues/399
|
||||||
|
if (!req->is_keep_alive()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue