1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine the http code.

This commit is contained in:
winlin 2015-06-14 19:42:43 +08:00
parent f8f6e438cc
commit 3211282b0c
4 changed files with 18 additions and 14 deletions

View file

@ -752,7 +752,7 @@ int SrsHlsMuxer::segment_close(string log_desc)
if (should_write_file) {
unlink(tmp_file.c_str());
if (unlink(tmp_file.c_str()) < 0) {
srs_warn("drop unlink path failed, file=%s.", tmp_file.c_str());
srs_warn("ignore unlink path failed, file=%s.", tmp_file.c_str());
}
}

View file

@ -1204,26 +1204,28 @@ int SrsHttpConn::process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
return ret;
}
SrsStaticHttpConn::SrsStaticHttpConn(IConnectionManager* cm, st_netfd_t fd, ISrsHttpServeMux* m)
SrsResponseOnlyHttpConn::SrsResponseOnlyHttpConn(IConnectionManager* cm, st_netfd_t fd, ISrsHttpServeMux* m)
: SrsHttpConn(cm, fd, m)
{
}
SrsStaticHttpConn::~SrsStaticHttpConn()
SrsResponseOnlyHttpConn::~SrsResponseOnlyHttpConn()
{
}
int SrsStaticHttpConn::on_got_http_message(ISrsHttpMessage* msg)
int SrsResponseOnlyHttpConn::on_got_http_message(ISrsHttpMessage* msg)
{
int ret = ERROR_SUCCESS;
// TODO: FIXME: use the post body.
std::string res;
ISrsHttpResponseReader* br = msg->body_reader();
// get response body.
if ((ret = msg->body_read_all(res)) != ERROR_SUCCESS) {
// drop all request body.
while (!br->eof()) {
char body[4096];
if ((ret = br->read(body, 4096, NULL)) != ERROR_SUCCESS) {
return ret;
}
}
return ret;
}

View file

@ -394,12 +394,14 @@ private:
virtual int process_request(ISrsHttpResponseWriter* w, ISrsHttpMessage* r);
};
// TODO: FIXME: rename to SrsResponseOnlyHttpConn.
class SrsStaticHttpConn : public SrsHttpConn
/**
* drop body of request, only process the response.
*/
class SrsResponseOnlyHttpConn : public SrsHttpConn
{
public:
SrsStaticHttpConn(IConnectionManager* cm, st_netfd_t fd, ISrsHttpServeMux* m);
virtual ~SrsStaticHttpConn();
SrsResponseOnlyHttpConn(IConnectionManager* cm, st_netfd_t fd, ISrsHttpServeMux* m);
virtual ~SrsResponseOnlyHttpConn();
public:
virtual int on_got_http_message(ISrsHttpMessage* msg);
};

View file

@ -1219,7 +1219,7 @@ int SrsServer::accept_client(SrsListenerType type, st_netfd_t client_stfd)
#endif
} else if (type == SrsListenerHttpStream) {
#ifdef SRS_AUTO_HTTP_SERVER
conn = new SrsStaticHttpConn(this, client_stfd, http_server);
conn = new SrsResponseOnlyHttpConn(this, client_stfd, http_server);
#else
srs_warn("close http client for server not support http-server");
srs_close_stfd(client_stfd);