Skip to content

Commit

Permalink
For #1657, fix the jsonp bug
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Nov 5, 2020
1 parent fc21b31 commit d67b050
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 53 deletions.
12 changes: 7 additions & 5 deletions trunk/src/app/srs_app_http_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,13 @@ SrsHttpApi::~SrsHttpApi()

srs_error_t SrsHttpApi::on_start()
{
return srs_success;
srs_error_t err = srs_success;

if ((err = conn->set_jsonp(true)) != srs_success) {
return srs_error_wrap(err, "set jsonp");
}

return err;
}

srs_error_t SrsHttpApi::on_http_message(ISrsHttpMessage* req)
Expand Down Expand Up @@ -1742,10 +1748,6 @@ srs_error_t SrsHttpApi::start()
return srs_error_wrap(err, "set cors=%d", v);
}

if ((err = conn->set_jsonp(true)) != srs_success) {
return srs_error_wrap(err, "set jsonp");
}

return conn->start();
}

Expand Down
25 changes: 12 additions & 13 deletions trunk/src/app/srs_app_http_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,23 @@ srs_error_t SrsHttpConn::cycle()
srs_error_t SrsHttpConn::do_cycle()
{
srs_error_t err = srs_success;

// Notify the handler that we are starting to process the connection.
if ((err = handler_->on_start()) != srs_success) {
return srs_error_wrap(err, "start");
}

// set the recv timeout, for some clients never disconnect the connection.
// @see https://github.com/ossrs/srs/issues/398
skt->set_recv_timeout(SRS_HTTP_RECV_TIMEOUT);

SrsRequest* last_req = NULL;
SrsAutoFree(SrsRequest, last_req);

// initialize parser
if ((err = parser->initialize(HTTP_REQUEST)) != srs_success) {
return srs_error_wrap(err, "init parser for %s", ip.c_str());
}

// Notify the handler that we are starting to process the connection.
if ((err = handler_->on_start()) != srs_success) {
return srs_error_wrap(err, "start");
}

// process http messages.
for (int req_id = 0; (err = trd->pull()) == srs_success; req_id++) {
Expand Down Expand Up @@ -268,14 +273,8 @@ srs_error_t SrsHttpConn::set_crossdomain_enabled(bool v)

srs_error_t SrsHttpConn::set_jsonp(bool v)
{
srs_error_t err = srs_success;

// initialize parser
if ((err = parser->initialize(HTTP_REQUEST, v)) != srs_success) {
return srs_error_wrap(err, "init parser for %s", ip.c_str());
}

return err;
parser->set_jsonp(v);
return srs_success;
}

srs_error_t SrsHttpConn::set_tcp_nodelay(bool v)
Expand Down
2 changes: 1 addition & 1 deletion trunk/src/protocol/srs_service_http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ srs_error_t SrsHttpClient::initialize(string schema, string h, int p, srs_utime_
srs_freep(parser);
parser = new SrsHttpParser();

if ((err = parser->initialize(HTTP_RESPONSE, false)) != srs_success) {
if ((err = parser->initialize(HTTP_RESPONSE)) != srs_success) {
return srs_error_wrap(err, "http: init parser");
}

Expand Down
9 changes: 7 additions & 2 deletions trunk/src/protocol/srs_service_http_conn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ SrsHttpParser::~SrsHttpParser()
srs_freep(header);
}

srs_error_t SrsHttpParser::initialize(enum http_parser_type type, bool allow_jsonp)
srs_error_t SrsHttpParser::initialize(enum http_parser_type type)
{
srs_error_t err = srs_success;

jsonp = allow_jsonp;
jsonp = false;
type_ = type;

// Initialize the parser, however it's not necessary.
Expand All @@ -75,6 +75,11 @@ srs_error_t SrsHttpParser::initialize(enum http_parser_type type, bool allow_jso
return err;
}

void SrsHttpParser::set_jsonp(bool allow_jsonp)
{
jsonp = allow_jsonp;
}

srs_error_t SrsHttpParser::parse_message(ISrsReader* reader, ISrsHttpMessage** ppmsg)
{
srs_error_t err = srs_success;
Expand Down
5 changes: 3 additions & 2 deletions trunk/src/protocol/srs_service_http_conn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ class SrsHttpParser
public:
// initialize the http parser with specified type,
// one parser can only parse request or response messages.
// @param allow_jsonp whether allow jsonp parser, which indicates the method in query string.
virtual srs_error_t initialize(enum http_parser_type type, bool allow_jsonp = false);
virtual srs_error_t initialize(enum http_parser_type type);
// Whether allow jsonp parser, which indicates the method in query string.
virtual void set_jsonp(bool allow_jsonp);
// always parse a http message,
// that is, the *ppmsg always NOT-NULL when return success.
// or error and *ppmsg must be NULL.
Expand Down
32 changes: 16 additions & 16 deletions trunk/src/utest/srs_utest_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ VOID TEST(ProtocolHTTPTest, ChunkSmallBuffer)
io.append(mock_http_response2(200, "0d\r\n"));
io.append("Hello, world!\r\n");

SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));

char buf[32]; ssize_t nread = 0;
Expand All @@ -382,7 +382,7 @@ VOID TEST(ProtocolHTTPTest, ChunkSmallBuffer)
io.append(mock_http_response2(200, "0d\r\n"));
io.append("Hello, world!\r\n0\r\n\r\n");

SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));

char buf[32]; ssize_t nread = 0;
Expand All @@ -409,7 +409,7 @@ VOID TEST(ProtocolHTTPTest, ChunkSmallBuffer)
io.append(mock_http_response2(200, "0d\r\n"));
io.append("Hello, world!\r\n0\r\n\r\n");

SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));

char buf[32]; ssize_t nread = 0;
Expand All @@ -436,7 +436,7 @@ VOID TEST(ProtocolHTTPTest, ClientSmallBuffer)
io.append(" world!");
io.append("\r\n0\r\n\r\n");

SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));

char buf[32]; ssize_t nread = 0;
Expand All @@ -461,7 +461,7 @@ VOID TEST(ProtocolHTTPTest, ClientSmallBuffer)
io.append(mock_http_response2(200, "0d\r\n"));
io.append("Hello, world!\r\n0\r\n\r\n");

SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));

char buf[32]; ssize_t nread = 0;
Expand All @@ -478,7 +478,7 @@ VOID TEST(ProtocolHTTPTest, ClientSmallBuffer)
// If buffer is smaller than chunk, we could read N times to get the whole chunk.
if (true) {
MockBufferIO io; io.append(mock_http_response2(200, "0d\r\nHello, world!\r\n0\r\n\r\n"));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));

char buf[32]; ssize_t nread = 0;
Expand Down Expand Up @@ -513,7 +513,7 @@ VOID TEST(ProtocolHTTPTest, ClientRequest)
// Normal case, with chunked encoding.
if (true) {
MockBufferIO io; io.append(mock_http_response2(200, "0d\r\nHello, world!\r\n0\r\n\r\n"));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));
string res; HELPER_ASSERT_SUCCESS(msg->body_read_all(res));
EXPECT_EQ(200, msg->status_code());
Expand All @@ -522,7 +522,7 @@ VOID TEST(ProtocolHTTPTest, ClientRequest)
}
if (true) {
MockBufferIO io; io.append(mock_http_response2(200, "6\r\nHello!\r\n0\r\n\r\n"));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));
string res; HELPER_ASSERT_SUCCESS(msg->body_read_all(res));
EXPECT_EQ(200, msg->status_code());
Expand All @@ -533,7 +533,7 @@ VOID TEST(ProtocolHTTPTest, ClientRequest)
// Normal case, with specified content-length.
if (true) {
MockBufferIO io; io.append(mock_http_response(200, "Hello, world!"));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE, false));
SrsHttpParser hp; HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_RESPONSE));
ISrsHttpMessage* msg = NULL; HELPER_ASSERT_SUCCESS(hp.parse_message(&io, &msg));
string res; HELPER_ASSERT_SUCCESS(msg->body_read_all(res));
EXPECT_EQ(200, msg->status_code());
Expand Down Expand Up @@ -1418,7 +1418,7 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser)
r.in_bytes.push_back("\r\n");

SrsHttpParser p;
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST, false));
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST));

ISrsHttpMessage* msg = NULL;
HELPER_ASSERT_SUCCESS(p.parse_message(&r, &msg));
Expand All @@ -1436,7 +1436,7 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser)
r.in_bytes.push_back("\r\n");

SrsHttpParser p;
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST, false));
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST));

ISrsHttpMessage* msg = NULL;
HELPER_ASSERT_SUCCESS(p.parse_message(&r, &msg));
Expand All @@ -1455,7 +1455,7 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser)
r.in_bytes.push_back("\r\n");

SrsHttpParser p;
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST, false));
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST));

ISrsHttpMessage* msg = NULL;
HELPER_ASSERT_SUCCESS(p.parse_message(&r, &msg));
Expand All @@ -1476,7 +1476,7 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser)
r.in_bytes.push_back("\r\n");

SrsHttpParser p;
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST, false));
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST));

ISrsHttpMessage* msg = NULL;
HELPER_ASSERT_SUCCESS(p.parse_message(&r, &msg));
Expand All @@ -1498,7 +1498,7 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser)
r.in_bytes.push_back("\r\n");

SrsHttpParser p;
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST, false));
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST));

ISrsHttpMessage* msg = NULL;
HELPER_ASSERT_SUCCESS(p.parse_message(&r, &msg));
Expand All @@ -1516,7 +1516,7 @@ VOID TEST(ProtocolHTTPTest, HTTPMessageParser)
r.in_bytes.push_back("\r\n");

SrsHttpParser p;
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST, false));
HELPER_ASSERT_SUCCESS(p.initialize(HTTP_REQUEST));

ISrsHttpMessage* msg = NULL;
HELPER_ASSERT_SUCCESS(p.parse_message(&r, &msg));
Expand Down Expand Up @@ -1780,7 +1780,7 @@ VOID TEST(ProtocolHTTPTest, ParsingLargeMessages)
0x66, 0x6d, 0x74, 0x70, 0x3a, 0x31, 0x31, 0x39, 0x20, 0x61, 0x70, 0x74, 0x3d, 0x31, 0x32, 0x33, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x72, 0x74, 0x70, 0x6d, 0x61, 0x70, 0x3a, 0x31, 0x31, 0x34, 0x20, 0x72, 0x65, 0x64, 0x2f, 0x39, 0x30, 0x30, 0x30, 0x30, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x72, 0x74, 0x70, 0x6d, 0x61, 0x70, 0x3a, 0x31, 0x31, 0x35, 0x20, 0x72, 0x74, 0x78, 0x2f, 0x39, 0x30, 0x30, 0x30, 0x30, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x66, 0x6d, 0x74, 0x70, 0x3a, 0x31, 0x31, 0x35, 0x20, 0x61, 0x70, 0x74, 0x3d, 0x31, 0x31, 0x34, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x72, 0x74, 0x70, 0x6d, 0x61, 0x70, 0x3a, 0x31, 0x31, 0x36, 0x20, 0x75, 0x6c, 0x70, 0x66, 0x65, 0x63, 0x2f, 0x39, 0x30, 0x30, 0x30, 0x30, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x2d, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x3a, 0x46, 0x49, 0x44, 0x20, 0x31, 0x34, 0x34, 0x33, 0x36, 0x34, 0x38, 0x35, 0x32, 0x33, 0x20, 0x31, 0x30, 0x39, 0x31, 0x38, 0x39, 0x32, 0x33, 0x39, 0x39, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x34, 0x34, 0x33, 0x36, 0x34, 0x38, 0x35, 0x32, 0x33, 0x20, 0x63, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x33, 0x4c, 0x75, 0x6d, 0x55, 0x62, 0x6a, 0x6c, 0x70, 0x50, 0x4d, 0x79, 0x77, 0x45, 0x31, 0x52, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x34, 0x34, 0x33, 0x36, 0x34, 0x38, 0x35, 0x32, 0x33, 0x20, 0x6d, 0x73, 0x69, 0x64, 0x3a, 0x76, 0x72, 0x79, 0x33, 0x6b, 0x78, 0x38, 0x4f, 0x44, 0x50, 0x77, 0x48, 0x45, 0x55, 0x71, 0x74, 0x67, 0x34, 0x6a, 0x51, 0x65, 0x37, 0x6d, 0x63, 0x4b, 0x5a, 0x58, 0x6d, 0x34, 0x41, 0x6b, 0x79, 0x54, 0x4f, 0x49, 0x42, 0x20, 0x37, 0x63, 0x37, 0x31, 0x37, 0x66, 0x36, 0x39, 0x2d, 0x62, 0x63, 0x33, 0x35, 0x2d, 0x34, 0x30, 0x38, 0x39, 0x2d, 0x38, 0x34, 0x63, 0x65, 0x2d, 0x34, 0x31, 0x65, 0x61, 0x38, 0x65, 0x31, 0x63, 0x34, 0x33, 0x39, 0x31, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x34, 0x34, 0x33, 0x36, 0x34, 0x38, 0x35, 0x32, 0x33, 0x20, 0x6d, 0x73, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3a, 0x76, 0x72, 0x79, 0x33, 0x6b, 0x78, 0x38, 0x4f, 0x44, 0x50, 0x77, 0x48, 0x45, 0x55, 0x71, 0x74, 0x67, 0x34, 0x6a, 0x51, 0x65, 0x37, 0x6d, 0x63, 0x4b, 0x5a, 0x58, 0x6d, 0x34, 0x41, 0x6b, 0x79, 0x54, 0x4f, 0x49, 0x42, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x34, 0x34, 0x33, 0x36, 0x34, 0x38, 0x35, 0x32, 0x33, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3a, 0x37, 0x63, 0x37, 0x31, 0x37, 0x66, 0x36, 0x39, 0x2d, 0x62, 0x63, 0x33, 0x35, 0x2d, 0x34, 0x30, 0x38, 0x39, 0x2d, 0x38, 0x34, 0x63, 0x65, 0x2d, 0x34, 0x31, 0x65, 0x61, 0x38, 0x65, 0x31, 0x63, 0x34, 0x33, 0x39, 0x31, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x30, 0x39, 0x31, 0x38, 0x39, 0x32, 0x33, 0x39, 0x39, 0x20, 0x63, 0x6e, 0x61, 0x6d, 0x65, 0x3a, 0x33, 0x4c, 0x75, 0x6d, 0x55, 0x62, 0x6a, 0x6c, 0x70, 0x50, 0x4d, 0x79, 0x77, 0x45, 0x31, 0x52, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x30, 0x39, 0x31, 0x38, 0x39, 0x32, 0x33, 0x39, 0x39, 0x20, 0x6d, 0x73, 0x69, 0x64, 0x3a, 0x76, 0x72, 0x79, 0x33, 0x6b, 0x78, 0x38, 0x4f, 0x44, 0x50, 0x77, 0x48, 0x45, 0x55, 0x71, 0x74, 0x67, 0x34, 0x6a, 0x51, 0x65, 0x37, 0x6d, 0x63, 0x4b, 0x5a, 0x58, 0x6d, 0x34, 0x41, 0x6b, 0x79, 0x54, 0x4f, 0x49, 0x42, 0x20, 0x37, 0x63, 0x37, 0x31, 0x37, 0x66, 0x36, 0x39, 0x2d, 0x62, 0x63, 0x33, 0x35, 0x2d, 0x34, 0x30, 0x38, 0x39, 0x2d, 0x38, 0x34, 0x63, 0x65, 0x2d, 0x34, 0x31, 0x65, 0x61, 0x38, 0x65, 0x31, 0x63, 0x34, 0x33, 0x39, 0x31, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x30, 0x39, 0x31, 0x38, 0x39, 0x32, 0x33, 0x39, 0x39, 0x20, 0x6d, 0x73, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3a, 0x76, 0x72, 0x79, 0x33, 0x6b, 0x78, 0x38, 0x4f, 0x44, 0x50, 0x77, 0x48, 0x45, 0x55, 0x71, 0x74, 0x67, 0x34, 0x6a, 0x51, 0x65, 0x37, 0x6d, 0x63, 0x4b, 0x5a, 0x58, 0x6d, 0x34, 0x41, 0x6b, 0x79, 0x54, 0x4f, 0x49, 0x42, 0x5c, 0x72, 0x5c, 0x6e, 0x61, 0x3d, 0x73, 0x73, 0x72, 0x63, 0x3a, 0x31, 0x30, 0x39, 0x31, 0x38, 0x39, 0x32, 0x33, 0x39, 0x39, 0x20, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x3a, 0x37, 0x63, 0x37, 0x31, 0x37, 0x66, 0x36, 0x39, 0x2d, 0x62, 0x63, 0x33, 0x35, 0x2d, 0x34, 0x30, 0x38, 0x39, 0x2d, 0x38, 0x34, 0x63, 0x65, 0x2d, 0x34, 0x31, 0x65, 0x61, 0x38, 0x65, 0x31, 0x63, 0x34, 0x33, 0x39, 0x31, 0x5c, 0x72, 0x5c, 0x6e, 0x22, 0x7d, 0x7d, 0x50, 0x4f, 0x53, 0x54, 0x20, 0x2f, 0x6a, 0x61, 0x6e, 0x75, 0x73, 0x2f, 0x32, 0x35, 0x38, 0x30, 0x34, 0x39, 0x32, 0x38, 0x30, 0x38, 0x36, 0x34, 0x32, 0x39, 0x31, 0x31, 0x39, 0x30, 0x32, 0x2f, 0x34, 0x32, 0x36, 0x38, 0x30, 0x33, 0x37, 0x39, 0x33, 0x30, 0x36, 0x34, 0x39, 0x33, 0x33, 0x36, 0x30, 0x38, 0x36, 0x20, 0x48, 0x54, 0x54, 0x50, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a, 0x48, 0x6f, 0x73, 0x74, 0x3a, 0x20, 0x33, 0x33, 0x2e, 0x31, 0x38, 0x2e, 0x34, 0x2e, 0x31, 0x32, 0x33, 0x3a, 0x31, 0x39, 0x38, 0x35, 0x0d, 0x0a, 0x55, 0x73, 0x65, 0x72, 0x2d, 0x41, 0x67, 0x65, 0x6e, 0x74, 0x3a, 0x20, 0x47, 0x6f, 0x2d, 0x68, 0x74, 0x74, 0x70, 0x2d, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x2f, 0x31, 0x2e, 0x31, 0x0d, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x3a, 0x20, 0x33, 0x35, 0x34, 0x0d, 0x0a, 0x41, 0x63, 0x63, 0x65, 0x70, 0x74, 0x2d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0x20, 0x67, 0x7a, 0x69, 0x70, 0x0d, 0x0a, 0x0d, 0x0a, 0x7b, 0x22, 0x6a, 0x61, 0x6e, 0x75, 0x73, 0x22, 0x3a, 0x22, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x6c, 0x65, 0x22, 0x2c, 0x22, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x22, 0x3a, 0x22, 0x62, 0x33, 0x31, 0x38, 0x65, 0x30, 0x32, 0x65, 0x32, 0x35, 0x34, 0x39, 0x35, 0x33, 0x30, 0x33, 0x61, 0x66, 0x39, 0x37, 0x66, 0x64, 0x36, 0x38, 0x38, 0x39, 0x35, 0x65, 0x35, 0x30, 0x62, 0x64, 0x22, 0x2c, 0x22, 0x63, 0x6c, 0x69, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x30, 0x6f, 0x77, 0x65, 0x67, 0x75, 0x35, 0x6f, 0x74, 0x66, 0x75, 0x30, 0x68, 0x64, 0x67, 0x6e, 0x68, 0x72, 0x6d, 0x6d, 0x76, 0x34, 0x63, 0x30, 0x79, 0x6b, 0x35, 0x67, 0x6e, 0x74, 0x38, 0x39, 0x22, 0x2c, 0x22, 0x72, 0x70, 0x63, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x22, 0x2c, 0x22, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x3a, 0x22, 0x73, 0x69, 0x67, 0x22, 0x2c, 0x22, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x7b, 0x22, 0x73, 0x64, 0x70, 0x4d, 0x4c, 0x69, 0x6e, 0x65, 0x49, 0x6e, 0x64, 0x65, 0x78, 0x22, 0x3a, 0x30, 0x2c, 0x22, 0x73, 0x64, 0x70, 0x4d, 0x69, 0x64, 0x22, 0x3a, 0x22, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x22, 0x2c, 0x22, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x22, 0x3a, 0x22, 0x63, 0x61, 0x6e, 0x64, 0x69, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x32, 0x35, 0x31, 0x30, 0x36, 0x35, 0x35, 0x31, 0x30, 0x39, 0x20, 0x31, 0x20, 0x75, 0x64, 0x70, 0x20, 0x34, 0x31, 0x38, 0x38, 0x35, 0x36, 0x39, 0x35, 0x20, 0x31, 0x31, 0x2e, 0x31, 0x33, 0x33, 0x2e, 0x31, 0x37, 0x32, 0x2e, 0x32, 0x34, 0x31, 0x20, 0x31, 0x30, 0x38, 0x30, 0x31, 0x20, 0x74, 0x79, 0x70, 0x20, 0x72, 0x65, 0x6c, 0x61, 0x79, 0x20, 0x72, 0x61, 0x64, 0x64, 0x72, 0x20, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x30, 0x20, 0x72, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x30, 0x20, 0x67, 0x65, 0x6e, 0x65, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x30, 0x20, 0x75, 0x66, 0x72, 0x61, 0x67, 0x20, 0x67, 0x4b, 0x2f, 0x62, 0x20, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2d, 0x69, 0x64, 0x20, 0x31, 0x20, 0x6e, 0x65, 0x74, 0x77, 0x6f, 0x72, 0x6b, 0x2d, 0x63, 0x6f, 0x73, 0x74, 0x20, 0x31, 0x30, 0x22, 0x7d, 0x7d
};
uint8_t* p = data; MockBufferIO io; SrsHttpParser hp;
HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_REQUEST, false));
HELPER_ASSERT_SUCCESS(hp.initialize(HTTP_REQUEST));

if (true) {
// First message, 144 header + 315 body.
Expand Down
Loading

0 comments on commit d67b050

Please sign in to comment.