mirror of
https://github.com/ossrs/srs.git
synced 2025-02-14 20:31:56 +00:00
Micro changes and fix utest fail.
This commit is contained in:
parent
1e6143e2eb
commit
d32bd72527
4 changed files with 22 additions and 23 deletions
|
@ -1011,8 +1011,6 @@ void SrsHttpResponseWriter::write_default_header()
|
|||
SrsHttpRequestWriter::SrsHttpRequestWriter(ISrsProtocolReadWriter* io)
|
||||
{
|
||||
writer_ = new SrsHttpMessageWriter(io, this);
|
||||
method_ = NULL;
|
||||
path_ = NULL;
|
||||
}
|
||||
|
||||
SrsHttpRequestWriter::~SrsHttpRequestWriter()
|
||||
|
@ -1040,10 +1038,10 @@ srs_error_t SrsHttpRequestWriter::writev(const iovec* iov, int iovcnt, ssize_t*
|
|||
return writer_->writev(iov, iovcnt, pnwrite);
|
||||
}
|
||||
|
||||
void SrsHttpRequestWriter::write_header(const char* method, const char* path)
|
||||
void SrsHttpRequestWriter::write_header(const std::string& method, const std::string& path)
|
||||
{
|
||||
if (writer_->header_wrote()) {
|
||||
srs_warn("http: multiple write_header calls, current=%s(%s), now=%s(%s)", method_, path_, method, path);
|
||||
srs_warn("http: multiple write_header calls, current=%s(%s), now=%s(%s)", method_.c_str(), path_.c_str(), method.c_str(), path.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -290,8 +290,8 @@ class SrsHttpRequestWriter : public ISrsHttpRequestWriter, public ISrsHttpFirstL
|
|||
protected:
|
||||
SrsHttpMessageWriter* writer_;
|
||||
// The method and path passed to WriteHeader, for request only.
|
||||
const char* method_;
|
||||
const char* path_;
|
||||
std::string method_;
|
||||
std::string path_;
|
||||
public:
|
||||
SrsHttpRequestWriter(ISrsProtocolReadWriter* io);
|
||||
virtual ~SrsHttpRequestWriter();
|
||||
|
@ -301,7 +301,7 @@ public:
|
|||
virtual SrsHttpHeader* header();
|
||||
virtual srs_error_t write(char* data, int size);
|
||||
virtual srs_error_t writev(const iovec* iov, int iovcnt, ssize_t* pnwrite);
|
||||
virtual void write_header(const char* method, const char* path);
|
||||
virtual void write_header(const std::string& method, const std::string& path);
|
||||
// Interface ISrsHttpFirstLineWriter
|
||||
public:
|
||||
virtual srs_error_t build_first_line(std::stringstream& ss, char* data, int size);
|
||||
|
|
|
@ -270,7 +270,7 @@ public:
|
|||
// Thus explicit calls to WriteHeader are mainly used to
|
||||
// send error codes.
|
||||
// @remark, user must set header then write or write_header.
|
||||
virtual void write_header(const char* method, const char* path) = 0;
|
||||
virtual void write_header(const std::string& method, const std::string& path) = 0;
|
||||
};
|
||||
|
||||
// Objects implementing the Handler interface can be
|
||||
|
|
|
@ -91,11 +91,12 @@ VOID TEST(TCPServerTest, PingPong)
|
|||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
EXPECT_TRUE(srs_netfd_fileno(l.lfd) > 0);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -108,7 +109,7 @@ VOID TEST(TCPServerTest, PingPong)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -130,7 +131,7 @@ VOID TEST(TCPServerTest, PingPong)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -154,7 +155,7 @@ VOID TEST(TCPServerTest, PingPong)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -189,7 +190,7 @@ VOID TEST(TCPServerTest, PingPongWithTimeout)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -211,7 +212,7 @@ VOID TEST(TCPServerTest, PingPongWithTimeout)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -233,7 +234,7 @@ VOID TEST(TCPServerTest, PingPongWithTimeout)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -413,7 +414,7 @@ VOID TEST(TCPServerTest, WritevIOVC)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -443,7 +444,7 @@ VOID TEST(TCPServerTest, WritevIOVC)
|
|||
|
||||
if (true) {
|
||||
MockTcpHandler h;
|
||||
SrsTcpListener l(&h);
|
||||
SrsTcpListener l(&h);
|
||||
l.set_endpoint(_srs_tmp_host, _srs_tmp_port);
|
||||
HELPER_EXPECT_SUCCESS(l.listen());
|
||||
|
||||
|
@ -515,12 +516,12 @@ VOID TEST(HTTPServerTest, MessageConnection)
|
|||
|
||||
if (true) {
|
||||
SrsHttpMessage m;
|
||||
m.set_basic(HTTP_REQUEST, 100, 0, 0); EXPECT_STREQ("<unknown>", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_GET, 0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_GET, m.method()); EXPECT_STREQ("GET", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_PUT, 0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_PUT, m.method()); EXPECT_STREQ("PUT", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_POST, 0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_POST, m.method()); EXPECT_STREQ("POST", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_DELETE, 0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_DELETE, m.method()); EXPECT_STREQ("DELETE", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_OPTIONS, 0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_OPTIONS, m.method()); EXPECT_STREQ("OPTIONS", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, (http_method)100, (http_status)0, 0); EXPECT_STREQ("<unknown>", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_GET, (http_status)0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_GET, m.method()); EXPECT_STREQ("GET", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_PUT, (http_status)0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_PUT, m.method()); EXPECT_STREQ("PUT", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_POST, (http_status)0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_POST, m.method()); EXPECT_STREQ("POST", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_DELETE, (http_status)0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_DELETE, m.method()); EXPECT_STREQ("DELETE", m.method_str().c_str());
|
||||
m.set_basic(HTTP_REQUEST, SRS_CONSTS_HTTP_OPTIONS, (http_status)0, 0); EXPECT_EQ(SRS_CONSTS_HTTP_OPTIONS, m.method()); EXPECT_STREQ("OPTIONS", m.method_str().c_str());
|
||||
}
|
||||
|
||||
if (true) {
|
||||
|
|
Loading…
Reference in a new issue