winlin

refine http code, define CRLF consts for http

... ... @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifdef SRS_HTTP_CALLBACK
#include <sstream>
using namespace std;
#include <stdlib.h>
#include <sys/socket.h>
... ... @@ -37,6 +38,8 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_kernel_log.hpp>
#include <srs_app_socket.hpp>
using namespace srs;
#define SRS_DEFAULT_HTTP_PORT 80
#define SRS_HTTP_RESPONSE_OK "0"
... ... @@ -150,13 +153,13 @@ int SrsHttpClient::post(SrsHttpUri* uri, std::string req, std::string& res)
// POST %s HTTP/1.1\r\nHost: %s\r\nContent-Length: %d\r\n\r\n%s
std::stringstream ss;
ss << "POST " << uri->get_path() << " "
<< "HTTP/1.1\r\n"
<< "Host: " << uri->get_host() << "\r\n"
<< "Connection: Keep-Alive" << "\r\n"
<< "Content-Length: " << std::dec << req.length() << "\r\n"
<< "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << "\r\n"
<< "Content-Type: text/html" << "\r\n"
<< "\r\n"
<< "HTTP/1.1" << CRLF
<< "Host: " << uri->get_host() << CRLF
<< "Connection: Keep-Alive" << CRLF
<< "Content-Length: " << std::dec << req.length() << CRLF
<< "User-Agent: " << RTMP_SIG_SRS_NAME << RTMP_SIG_SRS_VERSION << CRLF
<< "Content-Type: text/html" << CRLF
<< CRLF
<< req;
SrsSocket skt(stfd);
... ...
... ... @@ -31,6 +31,24 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_st.hpp>
// http specification
namespace srs
{
// CR = <US-ASCII CR, carriage return (13)>
const static char CR = '\r';
// LF = <US-ASCII LF, linefeed (10)>
const static char LF = '\n';
// SP = <US-ASCII SP, space (32)>
const static char SP = ' ';
// HT = <US-ASCII HT, horizontal-tab (9)>
const static char HT = 9;
// HTTP/1.1 defines the sequence CR LF as the end-of-line marker for all
// protocol elements except the entity-body (see appendix 19.3 for
// tolerant applications).
const static char* CRLF = "\r\n";
};
#ifdef SRS_HTTP_CALLBACK
class SrsRequest;
... ...
... ... @@ -31,11 +31,11 @@ SrsHttpApi::SrsHttpApi(SrsServer* srs_server, st_netfd_t client_stfd)
{
}
SrsHttpApi::~SrsHttpApi()
SrsHttpApi::~SrsHttpApi()
{
}
int SrsHttpApi::do_cycle()
int SrsHttpApi::do_cycle()
{
int ret = ERROR_SUCCESS;
... ...