正在显示
3 个修改的文件
包含
30 行增加
和
9 行删除
| @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 26 | #ifdef SRS_HTTP_CALLBACK | 26 | #ifdef SRS_HTTP_CALLBACK |
| 27 | 27 | ||
| 28 | #include <sstream> | 28 | #include <sstream> |
| 29 | +using namespace std; | ||
| 29 | 30 | ||
| 30 | #include <stdlib.h> | 31 | #include <stdlib.h> |
| 31 | #include <sys/socket.h> | 32 | #include <sys/socket.h> |
| @@ -37,6 +38,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -37,6 +38,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 37 | #include <srs_kernel_log.hpp> | 38 | #include <srs_kernel_log.hpp> |
| 38 | #include <srs_app_socket.hpp> | 39 | #include <srs_app_socket.hpp> |
| 39 | 40 | ||
| 41 | +using namespace srs; | ||
| 42 | + | ||
| 40 | #define SRS_DEFAULT_HTTP_PORT 80 | 43 | #define SRS_DEFAULT_HTTP_PORT 80 |
| 41 | #define SRS_HTTP_RESPONSE_OK "0" | 44 | #define SRS_HTTP_RESPONSE_OK "0" |
| 42 | 45 | ||
| @@ -150,13 +153,13 @@ int SrsHttpClient::post(SrsHttpUri* uri, std::string req, std::string& res) | @@ -150,13 +153,13 @@ int SrsHttpClient::post(SrsHttpUri* uri, std::string req, std::string& res) | ||
| 150 | // POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s | 153 | // POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s |
| 151 | std::stringstream ss; | 154 | std::stringstream ss; |
| 152 | ss << "POST " << uri->get_path() << " " | 155 | ss << "POST " << uri->get_path() << " " |
| 153 | - << "HTTP/1.1\r\n" | ||
| 154 | - << "Host: " << uri->get_host() << "\r\n" | ||
| 155 | - << "Connection: Keep-Alive" << "\r\n" | ||
| 156 | - << "Content-Length: " << std::dec << req.length() << "\r\n" | ||
| 157 | - << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << "\r\n" | ||
| 158 | - << "Content-Type: text/html" << "\r\n" | ||
| 159 | - << "\r\n" | 156 | + << "HTTP/1.1" << CRLF |
| 157 | + << "Host: " << uri->get_host() << CRLF | ||
| 158 | + << "Connection: Keep-Alive" << CRLF | ||
| 159 | + << "Content-Length: " << std::dec << req.length() << CRLF | ||
| 160 | + << "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << CRLF | ||
| 161 | + << "Content-Type: text/html" << CRLF | ||
| 162 | + << CRLF | ||
| 160 | << req; | 163 | << req; |
| 161 | 164 | ||
| 162 | SrsSocket skt(stfd); | 165 | SrsSocket skt(stfd); |
| @@ -31,6 +31,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,6 +31,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | 31 | ||
| 32 | #include <srs_app_st.hpp> | 32 | #include <srs_app_st.hpp> |
| 33 | 33 | ||
| 34 | +// http specification | ||
| 35 | +namespace srs | ||
| 36 | +{ | ||
| 37 | + // CR = <US-ASCII CR, carriage return (13)> | ||
| 38 | + const static char CR = '\r'; | ||
| 39 | + // LF = <US-ASCII LF, linefeed (10)> | ||
| 40 | + const static char LF = '\n'; | ||
| 41 | + // SP = <US-ASCII SP, space (32)> | ||
| 42 | + const static char SP = ' '; | ||
| 43 | + // HT = <US-ASCII HT, horizontal-tab (9)> | ||
| 44 | + const static char HT = 9; | ||
| 45 | + | ||
| 46 | + // HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all | ||
| 47 | + // protocol elements except the entity-body (see appendix 19.3 for | ||
| 48 | + // tolerant applications). | ||
| 49 | + const static char* CRLF = "\r\n"; | ||
| 50 | +}; | ||
| 51 | + | ||
| 34 | #ifdef SRS_HTTP_CALLBACK | 52 | #ifdef SRS_HTTP_CALLBACK |
| 35 | 53 | ||
| 36 | class SrsRequest; | 54 | class SrsRequest; |
| @@ -31,11 +31,11 @@ SrsHttpApi::SrsHttpApi(SrsServer* srs_server, st_netfd_t client_stfd) | @@ -31,11 +31,11 @@ SrsHttpApi::SrsHttpApi(SrsServer* srs_server, st_netfd_t client_stfd) | ||
| 31 | { | 31 | { |
| 32 | } | 32 | } |
| 33 | 33 | ||
| 34 | -SrsHttpApi::~SrsHttpApi() | 34 | +SrsHttpApi::~SrsHttpApi() |
| 35 | { | 35 | { |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | -int SrsHttpApi::do_cycle() | 38 | +int SrsHttpApi::do_cycle() |
| 39 | { | 39 | { |
| 40 | int ret = ERROR_SUCCESS; | 40 | int ret = ERROR_SUCCESS; |
| 41 | 41 |
-
请 注册 或 登录 后发表评论