mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
refine code, extract the http protocol sdk to module.
This commit is contained in:
parent
d645411392
commit
e2955da78f
9 changed files with 83 additions and 16 deletions
|
@ -58,7 +58,7 @@ using namespace std;
|
|||
|
||||
#define SRS_HTTP_DEFAULT_PAGE "index.html"
|
||||
|
||||
int srs_go_http_response_json(ISrsHttpResponseWriter* w, string data)
|
||||
int srs_http_response_json(ISrsHttpResponseWriter* w, string data)
|
||||
{
|
||||
w->header()->set_content_length(data.length());
|
||||
w->header()->set_content_type("application/json");
|
||||
|
|
|
@ -40,6 +40,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
||||
#include <srs_app_st.hpp>
|
||||
#include <srs_kernel_consts.hpp>
|
||||
#include <srs_http_stack.hpp>
|
||||
|
||||
class SrsRequest;
|
||||
class SrsStSocket;
|
||||
|
@ -72,7 +73,7 @@ class SrsConnection;
|
|||
#define SRS_HTTP_TS_SEND_BUFFER_SIZE 4096
|
||||
|
||||
// helper function: response in json format.
|
||||
extern int srs_go_http_response_json(ISrsHttpResponseWriter* w, std::string data);
|
||||
extern int srs_http_response_json(ISrsHttpResponseWriter* w, std::string data);
|
||||
|
||||
// state of message
|
||||
enum SrsHttpParseState {
|
||||
|
|
|
@ -59,7 +59,7 @@ int SrsGoApiRoot::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiApi::SrsGoApiApi()
|
||||
|
@ -81,7 +81,7 @@ int SrsGoApiApi::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiV1::SrsGoApiV1()
|
||||
|
@ -112,7 +112,7 @@ int SrsGoApiV1::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiVersion::SrsGoApiVersion()
|
||||
|
@ -137,7 +137,7 @@ int SrsGoApiVersion::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiSummaries::SrsGoApiSummaries()
|
||||
|
@ -152,7 +152,7 @@ int SrsGoApiSummaries::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
{
|
||||
std::stringstream ss;
|
||||
srs_api_dump_summaries(ss);
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiRusages::SrsGoApiRusages()
|
||||
|
@ -193,7 +193,7 @@ int SrsGoApiRusages::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* req)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiSelfProcStats::SrsGoApiSelfProcStats()
|
||||
|
@ -263,7 +263,7 @@ int SrsGoApiSelfProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage*
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiSystemProcStats::SrsGoApiSystemProcStats()
|
||||
|
@ -298,7 +298,7 @@ int SrsGoApiSystemProcStats::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessag
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiMemInfos::SrsGoApiMemInfos()
|
||||
|
@ -334,7 +334,7 @@ int SrsGoApiMemInfos::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiAuthors::SrsGoApiAuthors()
|
||||
|
@ -359,7 +359,7 @@ int SrsGoApiAuthors::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiRequests::SrsGoApiRequests()
|
||||
|
@ -420,7 +420,7 @@ int SrsGoApiRequests::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JOBJECT_END
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiVhosts::SrsGoApiVhosts()
|
||||
|
@ -445,7 +445,7 @@ int SrsGoApiVhosts::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JFIELD_ORG("vhosts", data.str())
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsGoApiStreams::SrsGoApiStreams()
|
||||
|
@ -470,7 +470,7 @@ int SrsGoApiStreams::serve_http(ISrsHttpResponseWriter* w, SrsHttpMessage* r)
|
|||
<< SRS_JFIELD_ORG("streams", data.str())
|
||||
<< SRS_JOBJECT_END;
|
||||
|
||||
return srs_go_http_response_json(w, ss.str());
|
||||
return srs_http_response_json(w, ss.str());
|
||||
}
|
||||
|
||||
SrsHttpApi::SrsHttpApi(IConnectionManager* cm, st_netfd_t fd, SrsHttpServeMux* m)
|
||||
|
|
24
trunk/src/protocol/srs_http_stack.cpp
Normal file
24
trunk/src/protocol/srs_http_stack.cpp
Normal file
|
@ -0,0 +1,24 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2015 SRS(simple-rtmp-server)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <srs_http_stack.hpp>
|
32
trunk/src/protocol/srs_http_stack.hpp
Normal file
32
trunk/src/protocol/srs_http_stack.hpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013-2015 SRS(simple-rtmp-server)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SRS_PROTOCOL_HTTP_HPP
|
||||
#define SRS_PROTOCOL_HTTP_HPP
|
||||
|
||||
/*
|
||||
#include <srs_http_stack.hpp>
|
||||
*/
|
||||
#include <srs_core.hpp>
|
||||
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue